PDA

View Full Version : Mozilla popup problem...


Dragzonox
09-02-2005, 06:26 PM
I'm using a code there looks like this:


<head>
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<title>Click on the image to close window.</title>
<STYLE type="text/css">
#loading{position:absolute; top:0; left:0; width:200; height:200;}
</STYLE>
<script language="javascript">
var arrTemp=self.location.href.split("?");
var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
var NS = (navigator.appName=="Netscape")?true:false;

function FitPic() {
iWidth = (NS)?window.innerWidth:document.body.clientWidth;
iHeight = (NS)?window.innerHeight:document.body.clientHeight;
iWidth = document.images[0].width - iWidth;
iHeight = document.images[0].height - iHeight;
window.resizeBy(iWidth, iHeight);
document.getElementById('loading').style.visibility = "hidden";
self.focus();
};
</script>
</head>


I have the "fix" for Netscape ( var NS = (navigator.appName=="Netscape")?true:false; ), but I miss it for Firefox, the image don't open in the right width, but it do open in the right height..
Can someone help me find the last code?
-Thank You

jscheuer1
09-02-2005, 06:55 PM
Try:
var NS = ((!document.all)||window.opera)?true:false;This is not a true test for Netscape but, it will branch between IE and virtually all other browsers. If this doesn't solve your problem in FF, then something about FF is preventing window resizing, like the FF default javascript settings, perhaps. Oh, and I think:

window.resizeTo(iWidth, iHeight)

is more universal.

Dragzonox
09-02-2005, 10:20 PM
When I use the

window.resizeTo(iWidth, iHeight)

The height is wrong to, so is the width...

var NS = ((!document.all)||window.opera)?true:false;
The code dosent do anything :S

jscheuer1
09-03-2005, 07:46 AM
That is because the script you are working from calculates the width of the window and subtracts that from the width of the image and likewise with the height. I'd really need to know just exactly you want to have happen and see a demo of your best attempt so far, to understand what you are really shooting for. FF will fight you though, if set to its defaults and you try to resize a window by whatever method. How do you expect Mozilla to know the dimensions of the image in the first place? Is it preloaded or do you supply the dimensions elsewhere?

Dragzonox
09-03-2005, 08:16 AM
Try to look at the site..
You will get an ider of what I want www.tg-gaming.dk

And it really is a bit wired, sometimes the image show up the right size, sometimes only the half of it..

jscheuer1
09-03-2005, 09:39 PM
It mostly hinges on the script having the width and height available to itself when needed. In IE that happens the instant the image begins to load. With Mozilla it takes a bit longer, so depending upon the bandwidth . . .

Since you are loading just the one image, if that is all you want to use this for, you could just put the actual dimensions in there instead of:

iWidth = document.images[0].width - iWidth;
iHeight = document.images[0].height - iHeight;
window.resizeBy(iWidth, iHeight);

use:

iWidth = 902
iHeight = 855
window.resizeTo(iWidth, iHeight);

This will not make Mozilla very happy when it is set to disallow the resizing of windows though. To get around that possibility, just open the window at the desired size to begin with:
function PopupPic(sPicURL) {
window.open( "popup.html?"+sPicURL, "",
"resizable=1,HEIGHT=902,WIDTH=855");
} If you are planning on using this script for multiple images from one page, the only way to use this method without knowing the dimensions in advance would be to preload the image and get its width and height, this would be best done onload and passed to the above function as needed at display time.

Dragzonox
09-04-2005, 09:47 AM
As you say, I'm planning to use it for multiple images when I get my site done..

I may just stick to the orginal code because most situations it works..