window.open in IE (invalid argument)

A quick IE issue. Calling window.open with spaces in the window name will error is IE but works fine in Firefox

Example

window.open(‘myPage.html’, ‘My New Page’);

will error

window.open(‘myPage.html’, ‘MyNewPage’);

will not :)

UPDATE: Thanks to all those who posted additions here. By the looks IE complains about a lot more than simply a space in the name – special characters are not good apparantly and to be avoided to avoid possible problems.

Advertisements

30 thoughts on “window.open in IE (invalid argument)

  1. you will also get an error with IE 6 if you use a .com in the window name. i.e.
    MyCTAwin=window.open(‘http://www.carulo.com/index.php’,’carulo.com’,’width=1000,height=500′)
    Will give invalid argument but this one won’t
    MyCTAwin=window.open(‘http://www.carulo.com/index.php’,’carulo’,’width=1000,height=500′)

    As usual, IE is still the worst browser around.

  2. “As usual, IE is still the worst browser around.” Obviously you haven’t done enough development with both Mozilla and IE to know that they both suck.

  3. @James:

    In terms of compliance Fabian speaks the truth. I’ve done more than enough development in both (it’s my main line of work) to know they both have issues, but nothing gives me more grief that IE6 in particular. I’ll admit 7 less so, but it still takes first prize on the “Browser’s to make you lose the will to live” contest. :)

  4. Such a simple thing, but it was driving me crazy at one point to figure out why it worked fine in FF but not in IE. Thank you for the information, it helps a lot =)

  5. Thanks, It helped me a lot.
    Don’t use any special characters(!, @, #, $, %, ^,….)in the Window name. If we use them they won’t work in IE browsers.

  6. Thanks. This really helps!

    btw, not only space gives the error. dash (-) also will contribute the same error.
    imo, don’t use any special characters in the name.

    Thanks IE too. =(

  7. Thanks a lot! I thought the problem was caused by the url^^

    the programmers of IE should type more often ‘bug IE’ into Google (and not bing, which probably filters all such combinations)

  8. ThankYou for you help. just to add to this it will also happen if you are using – in the window name aswell as spaces Ie my-new-site. will not work in IE

  9. spaces were causing the issue for IE 8 but in IE 9 nothing works actually window.open does not work in IE 9 was there any solution for this??

      1. I’ve tested this in IE9 at it appears that there is global setting in IE9 that forces all popups to open as new tabs. It appears at this point that there is no way to force this in code.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s