Ok, since my site is still down and I can’t point you to the long-winded article, here’s the nuts and bolts of getting external links to open in a new browser window and still be XHTML compliant:
As you may (or may not) know, using target=”_blank” in an anchor tag is illegal in XHTML strict. To get around this, it’s recommended you use rel=”external”. That’s all well and good, as it describes symantically what the relationship is (it’s an external link), but it doesn’t actually make the link open a new browser window.
So, the first step in this fix is to make sure any external link that you would like to open in a new window has rel=”external” as a parameter. You could write a script that parses exteral links (similar to LaughingLizard’s Waypath Hack), or not, depending on how you want to implement. Let’s say, for example, you just want to have the links on your sidebar open in a new window.
Find the line in your links.php file that is:
If you have more than one script that calls window.onload, or you have an onload event in your body tag, then remove the window.onload = externalLinks; line. Read this post for a short script that will load multiple onload events.
That’s it! Any link containing rel=”external” should now open in a new window, without breaking the XHTML strict validator!
- The topic ‘XHTML valid new windows’ is closed to new replies.