Previous Message
Next Message

Link targets using CSS

Sent by Moira Ashleigh on 27 March 2005 17:05


>Hey everyone.  I'd like to create a class of links that open up in a 
>new browser window (the HTML equivalent of target="_blank.")  I'm 
>sure this must be fairly easy.  I'm a beginner with CSS but have 
>been learning pretty fast as I've needed it to rebuild my webpage 
>using XHTML 1.0 strict.  Any help would be greatly appreciated :)

To deal with the XHTML strict recommendations and to still open a new 
page I found this page:
http://www.sitepoint.com/article/standards-compliant-world

for the use of javascript on a link as so:
<a href="http://www.foo.com" rel="external"></a>

JS:
function externalLinks() {
if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
    anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
  }
}
window.onload = externalLinks;

But what I don't get to be honest is the why being that "the removal 
of the target attribute from the Strict standards is that (X)HTML 
should only be concerned with the information that's displayed within 
a browser window." Because if you did that you should follow to 
remove hyperlinks all together, since they point off the page, and 
then why have the web. So the removal of target from (X)HTML forces 
people to use javascript which can be turned off. I do not see this 
as a bonus.

But to stay on CSS, I do understand since the link target doesn't 
have to do with the look of the page, as in Style Sheets, the target 
or reference to open a new window wouldn't belong in CSS.

Moira

-- 
Moira Ashleigh. M.A.
Lead Designer
SolsticeSun Design
http://www.solsticesun.com
[EMAIL-REMOVED]
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: