Jump to content

Won't Open New Window On Click


SmokingMan

Recommended Posts

I'm trying to open a new window when the link is clicked but it's not working. It just opens in the current window. Here's the code:

<a onclick="window.open(http://www.ThePointeChurch.net); return false;"	  onkeypress="window.open(http://www.ThePointeChurch.net); return false;"	  href="http://www.ThePointeChurch.net">	  <img alt="The PointeChurch" src="http://71.246.134.25/podcasts/ThePointeChurch.jpg" 	  title="The PointeChurch" height="200" width="200" /></a>

Should I include a separate <a> element inside a <noscript> instead of including the URL in the same <a> element as the JS function? Or have I written this incorrectly? I want this to open in a new window, but can't use the 'target' attribute and keep the page validated XHTML Strict.

Link to comment
Share on other sites

Your problem is that you need to put the URL within quotes in Javascript.By the way: if you were going for XHTML Strict, the width and height attributes are deprecated as well, use CSS instead.

<a href="http://www.thepointechurch.net" onclick="window.open('http://www.thepointechurch.net')">  <img style="width: 200px; height: 200px;"alt="The PointeChurch" src="http://71.246.134.25/podcasts/ThePointeChurch.jpg" title="The PointeChurch" /></a>

In fact, if your image is already 200x200px, you don't need to add the style attribute at all. (I'd suggest putting the image style in a stylesheet, but since width and height are usually specific to the image, it wouldn't change anything at all)

Link to comment
Share on other sites

Thanks for your help, I figured it was something simple.But:

By the way: if you were going for XHTML Strict, the width and height attributes are deprecated as well, use CSS instead.
When did these attributes become deprecated? The references I've used show them as a valid attribute for XHTML Strict, and my pages validate as such. Here's the link to XHTML.com and to W3Schools.
Link to comment
Share on other sites

Thanks for your help, I figured it was something simple.But:When did these attributes become deprecated? The references I've used show them as a valid attribute for XHTML Strict, and my pages validate as such. Here's the link to XHTML.com and to W3Schools.
Sorry, my mistake, but I still do recommend using CSS in the place of presentational attributes. Overall, to keep presentation and content separated.
Link to comment
Share on other sites

Interesting...

<!ELEMENT img EMPTY><!ATTLIST img  %attrs;  src		 %URI;		  #REQUIRED  alt		 %Text;		 #REQUIRED  longdesc	%URI;		  #IMPLIED  height	  %Length;	   #IMPLIED  width	   %Length;	   #IMPLIED  usemap	  %URI;		  #IMPLIED  ismap	   (ismap)		#IMPLIED  >

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...