PDA

View Full Version : Can I change 'href' of an anchor tag having no id or name using javascript?



abduraooft
Mar 15th, 2007, 04:46 PM
Hi friends...

I have an anchor tag


<a href="some.....?val1=val&....">

Can I modify the content of href using a javascript?

Please let me know..

Thanks in advance

regards,

art.

shyam
Mar 15th, 2007, 04:58 PM
sure u can


document.getElementById('target').href = 'anything';

<a id="target" href="some.....?val1=val&....">

abduraooft
Mar 15th, 2007, 05:03 PM
Thanks shyam for a quick response...

but,sorry i forgot to convey my situation.

I heared that there is a method to catch a control with document.getElementByTag method.

Can i use this for my problem, if so please let me know the correct function syntax

thnx,
art

Arty Effem
Mar 15th, 2007, 08:07 PM
Hi friends...

I have an anchor tag


<a href="some.....?val1=val&....">

Can I modify the content of href using a javascript?

Please let me know..

Thanks in advance

regards,

art.Are you saying that you want to change the href of a link that can not have a name or id assigned? If so it could be identified perhaps by its current href if known, or by its known position within a parent element.

felgall
Mar 15th, 2007, 10:36 PM
You could set up a loop to search for it in the document.links array.

abduraooft
Mar 16th, 2007, 08:58 AM
You could set up a loop to search for it in the document.links array.


thanks felgall..

it must suit for me!