Reputation: 755
I have a div called 'divLinks'
I want all links inside the divLinks to open in a new window.
How can I write a cross-browser effective script to achieve this?
Upvotes: 2
Views: 432
Reputation: 76736
Assuming "a div called 'divLinks'" means that the div has an id of 'divLinks'...
var links=document.getElementById('divLinks').getElementsByTagName('a'),
len=links.length, i;
for (i=len; i--;) { links[i].target='my_external_window'; }
Upvotes: 1