Window.Open Call Generates Invalid Argument Error in IE

Mindwatering Incorporated

Author: Tripp W Black

Created: 01/09/2008 at 05:42 PM

 

Category:
Notes Developer Tips
JavaScript

Issue:
Have window.open call which has error. IE is generating an error with message as "Invalid Argument".

Possible Solutions:
Check the following. This issue has been one of the following:
1. The window name has a space in it. The window name is the second parameter.
e.g. window.open(someurlpath, 'some name', winoptions);

2. The URL / URI was passed as one variable concatenated via computed text which was passed to the function at run time. This looks correct in the source but still blows up in IE 6. This seems to be an occasional IE 6 bug. Instead of passing the URL completed, which would normally be better code design, pass it in segments and recombined w/in the function. The URL is the first parameter.
e.g. window.open("/" + dbpath + "/dnelement", winnm, winoptions);

3. One of the options has a space. This blows up early IE versions. Concatenate the options w/o spaces between the = and , characters.
e.g. window.open(someurl, somenm, 'width=200,height=100');

4. In IE6, I had one case where the window.open was being called within the a link's onClick. The onClick window.open did NOTHING and the error message was slightly different each refresh on where in the code. Moving the window.open to a function ended up fixing the issue. It seemed to have been caused by the fact that the URL was pretty long, and there was a confirm (if) message that was long, too. The source text for those two lines were too much for IE 6 to "parse". By taking out one line and calling it via a function, IE seemed to behave.

previous page