469,290 Members | 2,009 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,290 developers. It's quick & easy.

Popups sometimes get blocked by IE

I'm working on a site for a friend. I've found some image popup code
that does what I want (borderless, close on exit) but for some reason
I occasionally get the "popup blocked" information bar in IE6.

Any suggestions?
Here is an example page, js code below:

http://www.aquariusyachting.co.uk/exterior.htm
var popwin='';

function viewPic(img)
{
picfile = new Image();
picfile.src =(img);
fileCheck(img);
}
function fileCheck(img)
{
if( (picfile.width!=0) && (picfile.height!=0) )
{
checkExisting(img);
}
else
{
funzione="fileCheck('"+img+"')";
intervallo=setTimeout(funzione,50);
}
}
function checkExisting(img)
{
if (popwin.location && !popwin.closed)
{
popwin.close();
makeWindow(img)
//popwin.location.href = img; needs a tidy here, but it works NM
// popwin.focus();
}
else {makeWindow(img)}
}
function makeWindow(img)
{
ht = picfile.height;
wd = picfile.width;

var args= "height=" + ht + ",innerHeight=" + ht;
args += ",width=" + wd + ",innerWidth=" + wd;

popwin=window.open("","_blank",args)
popwin.document.open()

popwin.document.write('<html><head><title>'+img+'</title></head><body
bgcolor=white scroll=no topmargin=0 leftmargin=0 rightmargin=0
bottomargin=0 marginheight=0 marginwidth=0> <div style="position:
absolute; top:0px;left:0px"><a href="javascript:window.close()"> <img
src="'+img+'" width="'+wd+'" height="'+ht+'"
border="0"></a></div></body></html>')
popwin.document.close()
}
function tidy() {
if (popwin.location && !popwin.closed) {
popwin.close(); }
}

// Based on JavaScript provided by Peter Curtis at www.pcurtis.com &
// http://www.therotunda.net/code/autos...up-window.html -->

--
Nigel M
Jul 23 '05 #1
7 1562
VK
If I read your Ezop language properly (I may not), then "a friend" is
"the target audience", so the question should be refrased as:

"For the visitors using IE 6 the number of shown popup ads is lesser
than the number of the registered visitors. What is the problem?"

The problem is that starting Windows XP SP2 popup blocker is finally
activated by default. So in the incoming times you need either to place
a text begging your visitors to allow popups (with instructions of
course), or (much more reliable) to move one on other alernatives
(popping up iframes or div's).

Jul 23 '05 #2
On 3 Jul 2005 01:57:07 -0700, VK wrote:
If I read your Ezop language properly (I may not), then "a friend" is
"the target audience", so the question should be refrased as:

"For the visitors using IE 6 the number of shown popup ads is lesser
than the number of the registered visitors. What is the problem?"


I'm sorry, I don't know what you mean.

The problem is that sometimes, an apparently random image will fail to
popup, and invoke the "popup blocked" information bar.
--
Nigel M
Jul 23 '05 #3
VK
> The problem is that sometimes, an apparently random image will fail to
popup, and invoke the "popup blocked" information bar.


OK, you may try this rather old script I used to use (I just cleaned it
of the NN4 stuff). Please mark the conventional way for image
buffering/error check. Your way is "too curly" to be reliable.

<script type="text/javascript">

var myPopup = null;
var myImage = null;

function init() {
myImage = new Image();
myImage.onload = showPopUp;
myImage.onerror = handleError;
document.getElementById('Buffer').insertBefore(myI mage,null);
getImage('foo.jpg');
}

function getImage(imgURL) {
myImage.src = imgURL;
}

function showPopUp() {
/* Image is buffered successfully */
/* It's time to display it */
var html = '<html><head><title>Click on image to close it</title>';
html+= '<style type="text/css">body {margin: 0px 0px}</style>';
html+= '</head><body>';
html+= '<img src="'+myImage.src+'" width='+myImage.width;
html+= ' height='+myImage.height;
html+= ' onmouseup="self.close()">';
html+= '</body></html>';
if ((myPopup != null)&&(!myPopup.closed)) {myPopup.close();}
var winParms = 'width='+myImage.width+',height='+myImage.height;
myPopup = window.open('','_blank',winParms);
with (myPopup.document) {
open('text/html','replace');
write(html);
close();
}
}

function handleError() {
/* Image cannot be obtained from the server */
/* Up to you: what to do */
}

window.onload = init;
</script>

And somewhere on your page:
....
<div id="Buffer" style="visibility: hidden">&nbsp;</div>
....

P.S. You cannot create popups lesser than 100px in width or height. An
attempt to create such pupup will trig security exception. How it will
be reacted is up to the browser. IE for example simply opens a default
size window. If you have picture lesser than 100px in any dimention,
you need to adjust your script.

Jul 23 '05 #4
On 5 Jul 2005 00:52:22 -0700, VK wrote:
OK, you may try this rather old script I used to use (I just cleaned it
of the NN4 stuff). Please mark the conventional way for image
buffering/error check. Your way is "too curly" to be reliable.


Many thanks for this, it certainly works when the page loads. Can you
suggest how I could modify it to pop up the image window when a
thumbnail is clicked?
--
Nigel M
Jul 23 '05 #5
VK
> how I could modify it to pop up the image window
when a thumbnail is clicked?


(1) In function init() comment out
// getImage('foo.jpg');

(2) Function getImage() changed as follows:
function getImage(evt, url) {
(evt.preventDefault) ? evt.preventDefault() : evt.returnValue = false;
myImage.src = url;
}

(3) In your page:
<a href="pic_1_big.jpg" onclick="getImage(event, this.href)">
<img src="pic1_thumb.gif" width="60" height="60" border="0">
</a>

But if you're doing thumbnail viewer, why do you need a buffering
anyway?? It's going to be very confusing for users, because they will
wondering if a link is dead or they have to wait for something. Just
open popup immediately upon click.

Jul 23 '05 #6
On 5 Jul 2005 04:13:35 -0700, VK wrote:
But if you're doing thumbnail viewer, why do you need a buffering
anyway?


I don't know if I do need buffering, but I pre-load the images as 1x1
pixels so the popups happen faster. Is there a better way?
--
Nigel M
Jul 23 '05 #7
VK
> I pre-load the images as 1x1 pixels
so the popups happen faster.
Is there a better way?


Pre-load may be good in such situation only if user has a high-speed
connection plus (s)he waits until your page is fully loaded (with all
"big images" buffered). If user has a rather slow connection and/or
user starts to click thumbnails before all big images are fully loaded,
it will produce a big mess in your script and bit irritation for user.
IMHO you should follow the common "browsing experience". Everyone's
learned that pictures in the browser never appear "right away", but
displayed part-by-part upon arrival. So it would be totally normal and
expected to open a popup for the big picture right upon the click on
the thumbnail, and let it be loading in view of the user.

If you care to make the waiting period the least boring for users, you
may convert all your GIF's into the *interlaced* format, and all your
JPG's into *progressive* format.

Jul 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

52 posts views Thread by Harlan Messinger | last post: by
1 post views Thread by Jim Mitchell | last post: by
2 posts views Thread by Tom Szabo | last post: by
reply views Thread by heathy | last post: by
4 posts views Thread by dd | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.