views:

1377

answers:

2

I have attached some javascript on onload event of the form. this script contains window.open. Although this works fine in all the browsers window.open doesn't open a new window nor it gives nay error message in google chrome and firefox.

I want to first check the screen resolution if it is less than 1024 then I would open it in a new window without menu,toolbar and others so that the user has more space to work on.

+5  A: 

This is a feature, not a bug! :)

remember back in the '90s when pop-up windows annoyed the crap out of everyone? Well, because of the MASSIVE abuse of that JavaScript behavior, now the only way to open windows is with direct user interaction; like a click.

Ariel
"Back in the 90's"? These horrors still exist, my friend!
Cerebrus
But this is supported by most of the browsers and i want to do it in safari and chrome too is there anyway to achieve this
Vinay Pandey
If it's "supported" by other browsers, those browsers should be updated to block unrequested windows.
eyelidlessness
It is not supported by other browsers — even IE, in its newer versions, now ships with a pop-up blocker on. Forget it.
bobince
+2  A: 

If you have a legitimate reason for opening another window, attach a click event to a button labeled such that it properly indicates you'll be opening a window. If your user wants to open the window, they will do so, and it will correctly get past any but the stupidest popup blockers. If they don't want to, you should not be opening a window in the first place.

eyelidlessness
Changed the settings that restricts popup and worked fine
Vinay Pandey
But you cannot change the settings on clients' machines. Do not rely on people turning off their popup blocker so you can avoid informing them that you will be opening a new window without their request!
eyelidlessness
something freaky occurs with Chrome. If you create a page which onload or jQ ready triggers a window.open and that window does something to the opener (try making it change a colour), notice that even though the child window is not displayed, the js is executed!!!? huh!?
Mr AH