Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Attributes of a Link 1

Status
Not open for further replies.

iaresean

Programmer
Mar 24, 2003
570
ZA
Anyone out there know of a method of changing a links attributes via javascript. Eg. the target, link, etc...

Any help is GREATLY appreciated.
 
Yup:

Code:
<a id=&quot;wibble&quot; href=&quot;&quot; target=&quot;&quot;>text</a>[code]

Can now be accessed using:

[code]
document.getElementById('wibble').setAttribute('href', '[URL unfurl="true"]http://www.google.co.uk/');[/URL]
document.getElementById('wibble').setAttribute('target', _blank');

etc etc etc

Hope this helps!

Dan
 

The same way you do it with anything else I'd have thought. Have you run into a problem with it?
 
BillyRay
Will this work if the href is not set by default to &quot;&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top