views:

227

answers:

2

Hi unable to open window.open on page load in ie8 If I use window.location its not opening in new page please help me out of this.

+2  A: 

This is because you're running into the popup blocker. This is a Good Thing(tm) :-) You can only open popups in response to the user taking an explicit action, like clicking something (and then typically only from within the event handler itself), not on things like page load where the unwitting user could be (and historically has been) inundated with dozens of windows opening all over the place. (And even doing it in response to an explicit user action may not be allowed by some blockers.)

T.J. Crowder
Hi thanks for your repl,y but its still working in mozilla and other browsers and window.open(window.location.href,'_blank') can do this, but I am unable to change the window.location.href value without reloading the page.
pavankumar
Changing the window.location.href amounts to navigating the current window to a new page. If you need to window.open() another url, store it in a var before you change it. But I think you'll find T.J. has a point.
Tor Haugen
Hi please find this url http://www.eenadu.net they are able to do that, they are opening popup on load could u please find this? the same thing I want to replicate in my application please help. Ofcourse its an html page but I want it for rtf file.
pavankumar
@pavankumar: 1. They aren't successfully opening a popup on load for me (not on Chrome, not on Firefox -- on Firefox I get the warning that they tried but it was blocked). 2. When you say "RTF file", I assume that that's what you want in the popup, not your main page. It doesn't matter what the popup's content is, it's how you trigger it. Perhaps if you tell us what you're actually trying to do (for instance, trigger a file download?), we'll be more likely to be able to help.
T.J. Crowder
A: 

Are no-one seeing a big problem with running window.open(window.location.href,'_blank') in the onload handler?

This is systematically a recursive function which would continue until the user manages to close the new window prior to the onload handler running.

I'm not saying that this has anything to do with the problem it might just be that IE8 is clever enough to see this..

Sean Kinsey
*"...it might just be that IE8 is clever enough..."* That...seems unlikely. ;-)
T.J. Crowder