Javascript, popups, and Internet Explorer

Opening a popup window is supposedly an easy task. Your user clicks on a link, you fire, and be done with it. Unless you need it to work with IE.

To the chase: has 3 arguments, the second of which, according to specs, is defined as

Optional. Specifies the target attribute or the name of the window. The following values are supported:

  • _blank - URL is loaded into a new window. This is default
  • _parent - URL is loaded into the parent frame
  • _self - URL replaces the current page
  • _top - URL replaces any framesets that may be loaded
  • name - The name of the window

The only difference with the documentation in MSDN is that the name option is ommited. In most tutorials or other forms of online doumentation, the name is used, to be able to refer to the newly created window. For some reason, IE decided that being able to refer to windows is highly overrated, and throws a warning if you use anything other than the other options. Obviously, without opening the popup window.

And in traditional MS fashion, the error is generic enough to not make much sense, until you know what the problem is --

Invalid argument on line 2524, column 5

Note that the column number refers to the first letter of the statement, not the argument... that'd be too easy. It's far easier to assume that the error is with the third argument, which is a concatenated list of (possibly also unsupported) options for the new window.

The easy way out is to just leave the second argument blank. Noone will complain that way, and in all cases, the default is _blank which is usually the desired behaviour for a popup.

I'm just too frustrated for losing a couple of hours to debug IE compatibility ... once more.


P.S. The T-Shirt image ( which I'm definently going to make a print version of ) comes from the site of O.C. Search Consulting. Thanks for the idea!