vs target=”_blank”

Like most people who have migrated to XHTML for web development, I stopped using target="_blank" for opening links in new windows in favor of onclick="; return false". They accomplish the same thing (opening the link in a new window) and the second one validates.

However, as I was implementing the often requested “open external links in new windows” preference for FeedLounge, I ended up falling back on the target="_blank" method for one simple reason: it works better.

Actually, I guess it isn’t so much that it works better as it is that browsers handle it better and more consistently.

The JavaScript method wants to pop a window no matter what. Even if you do a modified click to open the link in a new tab, you’ve got a 50-50 chance of getting the same link being opened in a new window as well1. When using the target method, browsers seem to have all decided that a new tab is just as good as a new window, and that there is no need to pop that superfluous window.

From a coding perspective, I can understand the browser’s behavior with the method. It received 2 commands:

  1. Open this link in a new tab.
  2. Open this link in a new window.

and it happily did both. Unfortunately, this isn’t the behavior that users actually want. Until we’ve got a standards compliant way of coding up the behavior that users want (open in a new tab if they hold down the modifier key), I’m going with the solution that will make my users happy – ugly non-compliant hack or not.

  1. A major annoyance of mine on Yahoo! sports pages. [back]

This post is part of the project: FeedLounge. View the project timeline for more context on this post.