resizeBy in Safari 3?

RJM62

Touchdown! Greaser!
Joined
Jun 15, 2007
Messages
13,157
Location
Upstate New York
Display Name

Display name:
Geek on the Hill
I'm trying to write a PHP / JavaScript method to automatically resize a popup window to the image it contains. This is basically to replace Peter Todorov's old JavaScript method, which doesn't work well with IE7 or FF 2.

I have a kludgy script that can be accessed from this page that works with IR7 and FF2, but no matter what I do, I can't get the popup window to vertically resize in Safari 3.

I'm using functions of

document.body.clientWidth / (Height) for IE,

and

window.innerHeight plus an odd bugfix for FF

to resize the windows, thusly:

_____________________

<?php
$imgURL = $_GET['img'];
list($width, $height) = getimagesize($imgURL);
$ffbugfix = 116;
?>

<html>
<head>

<script language="javascript">
var pWidth = "<?php echo $width ?>";
var pHeight = "<?php echo $height ?>";
var pic = "<?php echo $imgURL ?>";
var ffBugfix = "<?php echo $ffbugfix ?>";
function fitPic() {

if (Array.every) {
window.resizeBy(pWidth-ffBugfix, pHeight-window.innerHeight);
self.focus();
}
else {
window.resizeBy(pWidth-document.body.clientWidth, pHeight-document.body.clientHeight);
self.focus();
}
}
</script>

</head>

<body onload='fitPic();'topmargin="0" bottommargin="0" marginheight="0" leftmargin="0" rightmargin="0" marginwidth="0">
<div style="display:table">
<script language='javascript'>
document.write( "<img src='" + pic + "' width='" + pWidth + "' height='" + pHeight + "' border=0>" );
</script>
</div>
</body>
</html>

________________________

pHeight and pWidth are assigned according to information passed from a simple script that creates the initial window, which also appends the URL of the image. The PHP script then uses getimagesize to ascertain the dimensions.

The script works fine in IE7 and FF2, but nothing I do seems to have any effect on the vertical window size in Safari. I haven't tested it on other browsers yet.

Any ideas?

Thanks,

Rich
 
Last edited:
Back
Top