A blog post from danboe.net

Opening a link in a new window

Posted Jun 29, 2005 at 12:16 PM

XHTML 1.0 Strict has deprecated the target attribute for opening links in new windows.

So, here are the options available to us:

  1. Use a traditional link that does not open a new window. Users will love you for it.
  2. Use a link with an onclick event attribute instead. There are a few issues with this approach:
    1. There is no href defined, so styles only specificying a as their CSS selector won’t apply.
    2. Users with script disabled or without script support cannot navigate to the destination.
  3. Use a modified link with both an href and an onclick event attribute. This way, users get to navigate regardless of their script support or enabled state.

If desired, you can also target the position and size of the opened window with a slightly modified approach that uses this.href and passes more information to the window.open method.

Of course, as a user of the Internet, I strongly encourage you to revisit any requirements that cause your page to open more windows.


Visitor comments

1 comments

This post is closed to new comments. Thanks to everyone who commented.

About this page

This page contains a single post from Daniel Boerner's blog, of which Boot Camp + Windows Vista = no more Airport Extreme reboots is the latest post.

Are there more posts like this one?

Possibly. Within this blog, this post is categorized under webdev and it was posted on June 29, 2005. Those would be good places to start looking for related posts.

Next post (newer)

Previous post (older)