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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting if user is blocking pop-ups

Status
Not open for further replies.

GaryCam

Programmer
Dec 16, 2003
69
US
I have a site with some thumbnails on it. When the visitor clicks on a thumbnail, the full-size image appears in a new window. As I understand it, "new window==pop-up" so anyone who is blocking pop-ups won't see the full sized images. Can a script check for pop-up blocking and, if it exists, ask the user to temporarily disable it (via message box?)?

Or is there a better way of accomplishing this without opening a new window at all?
 
If you are using target="_blank" in your <a> tags, then a new window should be created anyhow for the high resolution image, this isn't classed as a 'pop-up'. I assume this is all you need.


Regards, Andy.
**************************************
My pathetic attempts at learning HTML can be laughed at here:
 
Thanks for the reply, Andy, but I beg to differ. IE now blocks these windows for users who have the blocker set to medium or high. I think this is new since installing WinXP SP2. Any other suggestions?

Regards, Gary
 
Javascript can probably do it. This, however, is client-dependent.
Code:
<html>
<head>
<script type="text/javascript">
<!--

var popup = window.open("","test","width=0,height=0");
if (!popup)
{
  alert("Popup blocker is enabled on this computer. \nPlease disable it while viewing this site.");
}
else
{
  popup.close();
}
// -->
</script>
</head>
<!-- rest of page -->
</html>

See the javascript forum, forum216, for details.

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
GarCam, regarding "IE now blocks these windows for users who have the blocker set to medium or high."
Thanks for the correction, I wasn't aware of this.

Regards, Andy.
**************************************
My pathetic attempts at learning HTML can be laughed at here:
 
Gary I don't think you are right on the target=_blank being blocked on IE SP2. The new protections block any attempt to use script to open a new window.

Clicking a link is user initiated and is not subject (or not supposed to be subject) to the block. Have you found it to be different?

Wow JT that almost looked like you knew what you were doing!
 
Dont use window.open, you must create a model window. It is not classified as a new window and no popup blocker will close this type of window. I cant remember the excact code, but im microsoft's site type in modal windows and you should get the results you want.
 
... except modal windows are only available in IE. Boo!

*cLFlaVA
----------------------------
[tt]Sigs cause cancer.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top