Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Zoom not working 1

Status
Not open for further replies.

glenmac

Technical User
Jul 3, 2002
947
CA
I have a onclick event handler to try and zoom an image to twice it's size. By my way of thinking it should work but it doesn't!!. Can anyone tell me where my logic is messed up?
Code:
<img src="image.gif" style = "width:125; height:272;" alt="My Picture"onClick="this.style.width*2;this.style.height*2;">
All help greatly appreciated.

Glen
 
As a minor point, you need a space after your [alt] declaration and before your [onClick] declaration.

Try this:
Code:
onclick="h=this.height*2;w=this.width*2;this.style.width=w+'px';this.style.height=h+'px';"

(tested in Moz 1.8b and IE6).

You have to set the variables (h and w) to the desired value before changing the height or width, because Mozilla tries to restrain the ratio, so when you double the width, it automatically doubles the height. Otherwise, IE would double the height and width, whilst Moz would quadruple it.

<marc> i wonder what will happen if i press this...[ul][li]please tell us if our suggestion has helped[/li][li]need some help? faq581-3339[/li][/ul]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top