Adam Woods

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromAdam Woods
ToMe
Subjectquestion
Date13 October 2004 21:17
I am using your image popup autosize perfect fit script.  Sometimes I am
displaying a image larger than my screen resolution.  Is there a way to
limit the size so it doesn’t display bigger than the user screen???  It
would be very appreciated.  Thanks!!!
FromMe
ToAdam Woods
SubjectRe: limiting image size in popup script
Date14 October 2004 9:00
Adam,

after this line:

'var oH = document.images[0].height, oW = document.images[0].width;\n'+

add this (you may need to play with the numbers in the first line):

'var mH = screen.availHeight-50, mW = screen.availWidth-40;\n'+
'if( oH > mH || oW > mW ) {\n'+
'mH = mH \/ oH; mW = mW \/ oW;\n'+
'var zoomFactor = ( mH < mW ) ? mH : mW;\n'+
'oH = Math.floor( oH * zoomFactor );\n'+
'oW = Math.floor( oW * zoomFactor );\n'+
'document.images[0].height = oH;\n'+
'document.images[0].width = oW;\n'+
'}\n'+

Assuming I have got my maths correct, this should do what you need.

Hope this helps

Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromAdam Woods
ToMe
SubjectRe: limiting image size in popup script
Date14 October 2004 17:25
Perfect....thank you so much
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.