Jump to content

XHTML link, open in new window


mbt

Recommended Posts

The code you provided should work just fine. You just need an ALT attribute on the image and to close it with /> in order to make it compliant with XHTML Transitional.

Link to comment
Share on other sites

This is closer:

<a href="http://w3schools.invisionzone.com/index.php?" target="_blank"><img src="http://w3schools.invisionzone.com/style_images/6_logo.png"alt="image description" style="border-style: none" /></a>

Still, error: there is no attribute "target"

Link to comment
Share on other sites

As said before to validate in strict1) img must end with "/>"2) img must contain alt attribute3) you must also enclose <a><img /></a> within a block element<div ="gallery"><a href="http://w3schools.invisionzone.com/index.php?"><img src="http://w3schools.invisionzone.com/style_images/6_logo.png"alt="image description" style="border-style: none" /></a></div>the target="_blank" is not supported in Strict doc type, in transitional Yes, Strict No!To will either have to convert to Transitional or use javascript within Strictyou can target all images within the div container using onload to assign an id ref, and onclick function to assign javascript target functionwindow.onload=function(){var ParentContainer = document.getElementById("gallery");var ChildAnchors = ParentContainer.getElementsByTagName("a");for(i=0;i<ChildAnchors.length;i++){ChildAnchors.id="image"+i;ChildAnchors.onclick = function() {gohere(this);}}}function gohere(element){document.getElementById(element.id).target="_blank";}if javascript is disabled, it will open in the same window.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...