Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting "target=" with CSS

Status
Not open for further replies.

sonnysavage

Programmer
May 29, 2002
130
US
I am coding with XHTML 1.0 Strict regulations. I have thumbnailed images which are wrapped in an anchor tag that links to the full-sized image. I want to have the full-sized image load up in a new window. Using "target=whatever" works great, but it's not XHTML 1.0 Strict compliant code. I was wondering if anyone knows how to use CSS to perform this functionality.

Thanks!
 
This isn't actually CSS, but you can use javascript, something like this:

<html>
<head>
<title></title>
</head>
<body onload=&quot;ChangeAllLinks();&quot;>
<script language=&quot;javascript&quot;>

function ChangeAllLinks()
{
var di = document.links
for (i=0; i<di.length; i++)
{
di.target = '_blank'
}
}
</script>

<br>
<a href=&quot;date.asp&quot;>link to date.asp</a><br>
<a href=&quot; to google</a><br>

</body>
</html>

------------------------------------------------------------

BTW: I don't know exactly the XHTML 1.0 Strict compliant code but if you don't like the script above, maybe you can use:

<head>
<base target=&quot;_blank&quot;
</head>

Hope this helps
Erik <!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
oops,

This is the right code:

[ignore]
<html>
<head>
<title></title>
</head>
<body onload=&quot;ChangeAllLinks();&quot;>
<script language=&quot;javascript&quot;>

function ChangeAllLinks()
{
var di = document.links
for (i=0; i<di.length; i++)
{
di.target = '_blank'
}
}
</script>

<br>
<a href=&quot;date.asp&quot;>link to date.asp</a><br>
<a href=&quot; to google</a><br>

</body>
</html>
[/ignore]

<!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top