Click to See Complete Forum and Search --> : Pop ups


stavinski
08-25-2003, 09:39 AM
I have a site that uses image thumbnails, and a user can click the image to bring up a pop up showing the bigger image.

I was wondering if there is a way to capture an event from the pop up saying that it wasn't blocked, just in case the user has some sort of pop up blocker, if it doesnt load then some sort of message could be displayed telling them to turn off the pop up blocker software.

I was contemplating setting a timeout and testing for an onfocus event after like a second or so as the onload event would be activated after the image is loaded, depending on the connection this could vary quite a lot:)

Any suggestions?

Just out of curiosity what is the difference between:

setTimeout() and setInterval() apart from the latter seems to have less support in older browsers?

pyro
08-25-2003, 09:53 AM
#1: You should be able to do something like this:

<script type="text/javascript">
newwin = window.open()
if (!newwin) {
alert ("Please turn off any popup ad blocking software to view these images");
}
</script>

#2: setTimeout (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1203758) runs once, whereas setInterval (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1203669) runs at the interval specified (keeps running until clearInterval (http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1201732) is called...).

stavinski
08-25-2003, 10:51 AM
Just tried it on the Opera built in blocker doesnt seem to pick-up on the statement just makes it run a bit weird, suppose would work for some other blockers depending on how they work.

If I put it in a timeout wrapper and look for the focus event would this work?

Bet you can tell havent used Javascript Much ;)

setTimeout("checkIt()", 1000)

function checkIt(){

if (!newwin.onFocus)
alert("Disable all Pop Up Blocker Software");

}

pyro
08-25-2003, 11:05 AM
I would try something like this, then. It will use the popup to set a variable in the opening page, so we can just detect the value of that variable, and if it is the value set by the popup, we know it has opened.

Untested...
<script type="text/javascript">
window.open();
iswinopen = "no";
function winExists() {
if (iswinopen == "no") {
alert ("Please turn off any popup ad blocking software to view these images");
}
}
setTimeout("winExists()", 1000);
</script>

and on the popup...

<script type="text/javascript">
window.opener.iswinopen = "yes";
</script>