Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect Pop-ups 2

Status
Not open for further replies.
Joined
Oct 15, 2003
Messages
145
Location
US
is there a way to detect if a person has a pop-up blocker on - like there is a way to detect if they have cookies enabled - navigator.cookieEnabled ?
 
I did - and I modified it so it prints it to the screen instead of giving me the box thingy...YaY!

You've made my day!!
 
well may i make a suggestion?

Code:
var w = window.open();
if (!w) alert('popups need to be enabled');
else w.close();

this way, that popup that will open, will get closed.

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
I'd still like it if I didn't have to create a pop-up to see if pop-ups are enabled...but I guess I can't have it all...
 
hah - I just made that modificaton - otherwise it keeps the window open when they are enabled - and I don't want that.


var w = window.open();
if (!w) document.write('popups need to be enabled');
else
document.write('popups enabled');
w.close();
 
you need curly braces around your else. and i'd add one more condition;

Code:
var w = window.open();

if (!w) {
    document.write('popups need to be enabled');
} else {
    document.write('popups enabled');
    if (!w.closed) w.close();
}

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 

WyldGynjer,

This has been in the FAQ section of this forum for over a week now:

faq216-5752

It's amazing what searching can show up ;o)

Dan



[tt]D'ya think I got where I am today because I dress like Peter pan here?[/tt]

 
Yes...it is in the FAQ - but I didn't want to do it that way...I really want a way to do it w/o having to create a pop-up all together - but I really don't like the one in the FAQ because it calls a function - I didn't want to do it that way...

thanks
 
i didn't think about putting the if condition on the close - so thank you! On my machine the user doesn't even see the popup it happens so fast...

I appreciate your help!
 
The only problem with that method is that some popup blockers will return something when you try to open a popup even though no window actually opens!

I can't recall the exact circumstances, but I ran into that problem months ago and had a very difficult time working around it.

I'll see if I can find the details and post them here.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
For my purposes...I need to make sure that the popup opens - so are you saying that there is a scenerio where this code won't work - because it will say that it opened but it really didn't?

 
Yes, that's what I'm saying.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
actually, what was said is, "i think this may not work, but i can't be sure and can't show you a situation where it wouldn't".

nothing's foolproof.

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 

tsdragon said:
The only problem with that method is that some popup blockers will return something when you try to open a popup even though no window actually opens!

I can't recall the exact circumstances, but I ran into that problem months ago and had a very difficult time working around it.

Tracy,

Did you ever find that example? I'm interested as I'm going through my code snippets documenting them, and would like to know if there is a potential problem with this one.

Do you recall if it was browser-specific, or popup-blocker specific?

Thanks,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top