By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,728 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,728 IT Pros & Developers. It's quick & easy.

Using Javascript to add target attribute to links

P: n/a
Hi,

I have a page which is being generated by a CMS and I can't control
the links which are being outputted. I want to add a target =
"_parent" attribute to all the links on my page using javascript. Can
anyone tell me how to do it.

Thanks a lot.

Gerald.

Feb 19 '07 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Gerald Shastri wrote:
Hi,

I have a page which is being generated by a CMS and I can't control
the links which are being outputted. I want to add a target =
"_parent" attribute to all the links on my page using javascript. Can
anyone tell me how to do it.

Thanks a lot.

Gerald.
links=document.getElementsByTagName("a");
for(var i=0; i<links.length; i++) {
links[i].target="_parent";
}
--
http://www.hunlock.com -- Musings in Javascript, CSS.
$FA
Feb 19 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.