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="window.open(this.href); 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.
From a coding perspective, I can understand the browser’s behavior with the window.open method. It received 2 commands:
- Open this link in a new tab.
- 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.
- A major annoyance of mine on Yahoo! sports pages. [back]