aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to by pass pop up blockers while using window,open() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to by pass pop up blockers while using window,open() " Watch "How to by pass pop up blockers while using window,open() " New topic
Author

How to by pass pop up blockers while using window,open()

sreeni san
Ranch Hand

Joined: Aug 14, 2001
Posts: 39
Hi,

I am using a javascript function which opens a new window to launch the given URL.

function launch () {
target="/xyz/xyz"
y=window.open (target, "newwin", "scrollbars=yes, status=yes,menubar=no,resizable=yes");
y.focus;
}

When this function is called, the popup blocker on my browser is not allowing me to launch the new browser window.

Is there a way for me to find that there is an active popupblocker from the launch()java script and bypass the pop up blocker (without manully disabling the pop up blocker)? or may be is ther a way to find out that there is a pop up blocker so that a java script alert message can be shown to the user?

Thanks in advance.

Sreeni.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You can not bypass a pop up blocker, that would defeat their purpose!

Blogged about it here: http://radio.javaranch.com/pascarello/2005/05/12/1115907581343.html

Pop ups are normally blocked if they are created without a user ineraction. aka onload, onclose, timers.

Eric
Sonal Jogi
Greenhorn

Joined: Oct 19, 2004
Posts: 23
Hi, U can find whether a popup blocker is present using a simply javascript function:
function IsPopupBlocker() {
var oWin = window.open ("","testpopupblocker","width=100,height=50,top=5000,left=5000");
if (oWin==null || typeof(oWin)=="undefined") {
return true;
} else {
oWin.close();
return false;
}
}

And yes you can bypass a popup blocker by making contineous hits. Out of there hits, one would open sure shotly. have tried it out.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
If you were to do a loop, you have a big chance that you are going to freeze the browser of the user going to the site.
Sonal Jogi
Greenhorn

Joined: Oct 19, 2004
Posts: 23
No such problem had not occured till now. If 3 concurrent html statements are written for openeing a popup window, 2 get blocked but the trid one gets open.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Can I see the code and what browser and pop up blocker are you running?

I ran tests earilier and posted it on my blocg here:
http://radio.javaranch.com/pascarello/2005/05/24/1116946280225.html

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to by pass pop up blockers while using window,open()