On Jul 29, 2005, at 12:43 PM, Thierry Koblentz wrote:
One thing though-- what happens to mailto: links?
Good point! To be honnest with you I didn't even think about these :)
But they are "safe" because I'm checking for an "HTTP" string
inside the
attribute's value.
I think you ought to check specifically that 'http://' is at the
beginning of the string. This would help rule out false positives
like these:
<a href="/protocols/about_http.html">Find out about HTTP</a>
<a href="/affiliate.asp?ref=http://foo.com/bar.php">Set your
affiliation reference cookie</a>
In your code you have:
a[i].getAttribute('href').toUpperCase().indexOf("HTTP") >= 0
...and I think you might be better with:
a[i].getAttribute('href').toUpperCase().indexOf("HTTP://") == 0
And other than the design choice of whether all external links ought
to open a new window, I think you've got something good. I like your
idea of attaching the style and title with javascript so as to leave
the natural behavior intact.
Personally, I prefer the rel attribute, because when done well you
are expressing the arbitrary relationship the current document has to
the target document. If you only use rel to basically say "open a new
window" then that's not very semantic and it's coupling markup and
behavior closely. But if you use rel to say "some links are for other
content, others are for examples and figures, and either can be
external sites," and then use JS to set examples and figures on
external sites to open in new windows, then you're golden. Your rel
is meaningful and your behavior is attached to the meaning of the
markup.
--
Ben Curtis : webwright
bivia : a personal web studio
http://www.bivia.com
v: (818) 507-6613
******************************************************
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************