|
spinningjennie -> Alternatives to target=_blank for xhtml strict (7/3/2006 6:29:29)
|
What is the best alternative for target=_blank when using xhtml 1.0 strict? The w3c validator rejects it. I want my external links to open in a new window, so that if a viewer closes the window, they get back to my website. I've tried the following: 1. Used javascript in this page to link to this external.js file which contains the following code but I can't get it to work: function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank"; } } 2. I've also added text beside the links in this alternative page to get the viewer to use Shift + Click to open the links. It does work but I think it looks a bit unusual. 3. As an alternative I might change my document type from Strict HTML to Transitional HTML so that target=_blank is accepted. I haven't tried this yet. I would have to compromise on strict xhtml, so I was reluctant. Any advice much appreciated! spinningjennie
|
|
|
|