Email conversation
From | Claude Kleiman |
To | Me |
Subject | java script popup discussion2 |
Date | 22 November 2004 20:32 |
Hi,
Just in case you didn't get my message the first time. Here goes, again.
...
Dear Sir (I'm sorry but couldn't find your name on site),
I've been google searching for several days now and happened upon your
site.
Thank you for your section and script on perfect popups!
I have a script that I'm currently using that I really like! The script
autosizes the window of the popup and centers. What I really like is how
it opens.....it starts out as a small square and then opens up to resize
itself to the image. You almost have to see it in action so I've
provided a link; [demonstration page]
If you click on the image of the Tac 12T monitor you'll see the script
in action. Works perfect in IE.
The problem is FireFox. You get the scrollbars in the larger image.
Your article explains the reason and I feel much better now that I know
the facts.
Anyway, I give you the script below in hopes you can make it FireFox
compatible and share with me? and others. Here you go......
<script>function PopupImage(img) {
w=open('','image','top='+(screen.height/2-50)+',left='+(screen.width/2-5
0)+',width=1,height=1,toolbar=no,scrollbars=no,resizable=no');
w.document.write('<HTML><HEAD><TITLE>Tac 12T</TITLE></HEAD>');
w.document.write('<SCRIPT language=javascript>function checksize() ');
w.document.write(' { if (document.images[0].complete) {
window.moveTo((screen.width-document.images[0].width-12)/2,(screen.heigh
t-document.images[0].height-30)/2);
window.resizeTo(document.images[0].width+10,');
w.document.write('document.images[0].height+35); window.focus();} else {
setTimeout(\'check()\',250) } }</'+'SCRIPT>');
w.document.write('<BODY onBlur="self.focus()" onload="checksize()" ');
w.document.write('leftMargin=0 topMargin=0 marginwidth=0
marginheight=0><a onMouseOver="style.cursor=\'hand\';"
onClick="javascript:window.close();"><IMG src='+img+' border=0></a>');
w.document.write('</BODY></HTML>');
w.document.close();}</script>
<a class=image href='#'
onclick="javascript:PopupImage('images/Tac12Tbig.jpg')";>
Claude Kleiman
From | Me |
To | Claude Kleiman |
Subject | Re: java script popup discussion2 |
Date | 22 November 2004 21:56 |
Claude,
> Just in case you didn't get my message the first time. Here goes, again.
Sorry, never saw it the first time.
> Works perfect in IE.
And Opera, but you seem to have forgotten to check in that. Can't check in
Mac browsers today, but I suspect it would fail in those.
> The problem [I have] is FireFox.
Of course you do. You simply add 10 pixels to the width and 35 to the
height, and hope that it is enough for the window chrome. Different
browsers have different sized chrome. Different skins, different toolbars.
You simply cannot assume that all browsers will use the same static size.
That is the entire basis why I wrote my script in the first place. It takes
care of all these different chrome sizes for you. Simply replace your
script with my script. The one under the heading:
'Resizing a popup to perfectly fit an image, even if you do not know how
big that image is'
With the exception of the window title being passed as a parameter to the
function, it is pretty must a complete replacement for the one you are
using.
Change the defaultWidth and defaultHeight to 100 and 100, that will make it
start small.
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Claude Kleiman |
To | Me |
Subject | Re: java script popup discussion2 |
Date | 22 November 2004 22:50 |
Mark,
FYI,
Here's copy of my script, again.
Please note 10 pixels are already added to width and 35 already added to
height.
To get the scrollbars to disappear in Firefox I had to increase width to
25 and height to 80. The problem now was too much white space in IE!
From | Claude Kleiman |
To | Me |
Subject | Re: java script popup discussion2 |
Date | 22 November 2004 23:07 |
Mark,
I did the following;
PositionX = screen.width/2;
PositionY = screen.height/2;
Now it seems to open in the middle as long as I'm viewing at 1024 x 768.
This is the way my script was working, as well. Neither opens in the
center at 800 x 600, but, who cares?
Is this fix ok?
From | Me |
To | Claude Kleiman |
Subject | Re: java script popup discussion2 |
Date | 22 November 2004 23:11 |
Then use my script instead. it does not suffer from this problem
From | Claude Kleiman |
To | Me |
Subject | Re: java script popup discussion2 |
Date | 23 November 2004 01:20 |
Mark,
You've obviously done your homework! I just downloaded and installed
Opera for the first time and now I see why you make the X and Y
positions small.
I'm still considering using screen.width/2-50 for PositionX and
screen.height/2-50 for PositionY, which, works great for IE and FireFox,
but, puts the picture in lower left for Opera.
I would think Opera users are probably used to seeing some discrepancies
as they seem to be the third browser, although, they're advertising
close to 5,000,000 downloads, which, would put them close behind
FireFox.
Anyway, thanks much for your help and your script!
Claude Kleiman
From | Claude Kleiman |
To | Me |
Subject | feedback from Claude Kleiman re: image popup script |
Date | 24 November 2004 20:11 |
Hi Mark,
Took your advice and am using your script.
One little note; I've noticed when using wide sized images in Firefox at
800 x 600 some annoying white space is added to the right side until the
popup box fills the width of the screen.
You've already documented this problem on your site, but, I think it was
for problems with pictures that were too high not too wide. So FYI.
This is just a minor thing. The main thing is all works well at 1024x768
cross browser!
Well done! and thanks for your script!
Claude Kleiman