Jump to content

XHTML link, open in new window


mbt
 Share

Recommended Posts

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.

Edited by dsonesuk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...