The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

assign target to nested links only?

I'm looking for a way to use javascript to assign target="_blank" via javascript to all links that appear within a <td> with id="cms.
All other links should be left untouched (so they'll use the default _self target).

When you click anything in the td then the script looks at what the target element was (event.srcElement(IE) || e.target(NS)), if the nodeName is not an anchor tag you return nothing, if it is, you set it to blank.

I was looking at it thinking it was an automated script in the same way that Yank's 'New Window in a Standard Compliant World' script method is.
I was expecting something that would automatically preassign the target attribute to certain links onload.

Now I know what angle this script is coming from, I can see it more clearly.

Looking at it, one thing occurs to me...

How are non-IE browsers supposed to know what the e var is when it hasn't been defined?

Surely that's gonna cause the script to fail and throw an error in non-IE browsers, no?.

Edit:

Checked and non-IE browser do indeed fail the script.
Tested on Moz (Et al) and Opera.

Hmmm.. your right. I didn't test in NS or Opera just figured it would work. Netscape's e.target is probably conflicting with the already named links.target attribute. I'll have to think about a different way of doing of solving your problem.