Forum Moderators: open

Message Too Old, No Replies

Resize popup to image size - not working on Mac browsers

         

a_angova

12:08 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



Hello,

I have the following problem:

<html>
<head>
<title>enlarge.htm</title>
<script language="javascript" type="text/javascript">
image_1 = new Image()
image_1.src = "img/image_big.jpg"

//DetectImageSize function
function DetectImageSize(picName,picTitle){
picURL=picName.src

newWindow=window.open(picURL,'_blank','toolbar=no, left=200,top=100,scrollbars=no, width='+picName.width+',height='+picName.height)
newWindow.document.write('<html><head><title>'+picTitle+'<\/title><\/head><body background="'+picURL+'"><\/body><\/html>')
newWindow.resizeBy(picName.width-newWindow.document.body.clientWidth, picName.height-newWindow.document.body.clientHeight)
newWindow.focus()
}
//-->
</script>
</head>
<body>

<a href="javascript:DetectImageSize(image_1,'Title')">
<img src="img/image_small.jpg" alt="" class="image_bikini"/></a>

</body>
</html>

This script does not work on Mac browsers, crops the image opened in the new window. On PC everything is fine. Can anyone help me please :(

Best Regards,Ani

tedster

1:31 am on Aug 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Many browser versions ago, it helped to reload the window with history.go() if the OS was Macintosh. See if it helps.

if (navigator.appVersion.indexOf('Mac')!= -1)
history.go(0)
;

<added>

It just struck me that you could simplify the work on the browser by avoiding the resizeBy() step altogether. Since the script has got the width and height, just open the window that size to begin with, right?

a_angova

6:19 am on Aug 11, 2005 (gmt 0)

10+ Year Member



Hi, tedster

Thank you for your reply. I will try to remove the resize thing and the code for Mac and will inform you whether it works :)

Best Regards and Thank you again, Ani

dcrombie

9:18 am on Aug 11, 2005 (gmt 0)



[mozilla.org...]

clientWidth is part of the MSIE's DHTML object model.
clientWidth is not part of any W3C specification or technical recommendation.