Js click to zoom in and click zoom out.

102 4
function chgsize(e){
 if(e.getAttribute('big')&&e.getAttribute('big')=='1'){
 e.setAttribute('big','0');
 e.setAttribute('width','150');
 }else{
 e.setAttribute('big','1');
 e.setAttribute('width','500');
 }
}

It can only be used by default 150PX images, and click into 500px, but if the image is less than 500, the picture will be magnified, and if the picture is less than 500, if the image is
I added code to css. width: expression(this.width> 500 && this.width> this.height? 500 : auto); max-width:500px; But because of the priority relationship, it doesn't work, and you want to be able to help you change js.

2 Answers

118 4

In fact, when you click on the zoom, get the width of the larger image, and then try to see it. Let's say the picture is xx. Com/1. Jpg.
When you click on the zoom:

var big = new Image();
big.onload = function() {
 if ( this.offsetWidth> 500 ) {
//set width
 } else {
//not set width
 }
};
big.src = 'xx.com/1.jpg';

It's just a simple way to provide your own ideas, and I want to help you.

...