XHTML Popup Link

If you're writing XTHML 1.0 then you'll not be able to use the target attribute to open links in a new window AND have the page validate as XHTML. You can get around this with the use of JavaScript and the onclick (or onkeypress) event.

The javascript:

<script language="JavaScript" type="text/javascript">
function targetBlank (url) 
   blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');

The anchor:

<a href="http://mindspill.net" onclick="targetBlank(this.href);return false;">mindspill.net</a>

It will generate this link: mindspill.net.

Also See

If you want a truly accessible link, which does not rely on Javascript, read this article: A List Apart: Articles: Accessible Pop-up Links.

Last modified: 06/05/2006 (most likely earlier as a site migration in 2006 reset some dates) Tags: (none)

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top