Hi,
I am using the following code to open a blank page however this creates an HTML error.
Does anyone know the correct code to open a blank page. Im sure this used to work fine.
target="_blank" class='venuelink'
Hi,
I am using the following code to open a blank page however this creates an HTML error.
Does anyone know the correct code to open a blank page. Im sure this used to work fine.
target="_blank" class='venuelink'
Run for cover!
This no longer validates as it is considered bad practice. You are forcing the user to open a new window and you should really leave that decision up to the user. It also breaks back button functionality etc.
When you say “HTML error”, are you referring to a validation error? target=“_blank” is correct for HTML but is invalid for XHTML.
If you are using XHTML, you will have to use Javascript to open your target in a new window in order for it to validate. Like this:
onclick="window.open(this.href,'_blank'); return false;"
Complete link would be:
<a href="http://www.sitepoint.com/" onclick="window.open(this.href,'_blank'); return false;">Sitepoint</a>
The “return: false;” part is important.
You could also do something similar to this:
<a href="http://www.sitepoint.com/" onclick="window.open(this.href,'_blank'); return false;">Sitepoint</a>
Brilliant thanks, do I need to add anything to the head to allow it to recognise the Javascript?
Im using it on a directory which a blank window would work better.
Try to use sparingly: Should links open in new windows - http://uxdesign.smashingmagazine.com/2008/07/01/should-links-open-in-new-windows/