tags:

views:

401

answers:

3
alert(window.open('http://www.google.com'));

i tried this on firefox, and i get null, no prob in ie. any idea why?

+3  A: 

It certainly works for me in firefox. Could it be a popup-blocker?

Magnar
did the alert print print out null on firefox?
cometta
If you have no pop up blocker then it will print [object Window]
rahul
Note that if you drop a local file into Firefox with the original code (i.e. - non-user triggered `<script>alert(window.open(...));</script>`), Firefox does block the pop-up window and return `null`. It also presents the yellow bar across the top of the window indicating it blocked the pop-up (I'm pretty sure my settings are default).
Grant Wagner
A: 

I tried it and also got the result is in Message box Object and also the related web page opened.

When clicking the popup blocker it will ask security warning messsage just click yes with ctrl button you will get the result.

Ambut bhath
A: 

Firefox will return null as it's essentially a void method - you're asking it to alert(null).

window.open(''); I believe is a null method anyway - but it certainly works in FF 3.5 on 10.6

Tom Harvey
@Tom: `window.open()` blocks until the new window opens (or doesn't) and returns a reference to the newly opened window (or `null` if no new window was opened). So `alert(window.open(...));` should alert the value of the `toString()` method of the `window` object (`[object]` in IE, `[object Window]` in Firefox, etc).
Grant Wagner