Javascript:调整图像大小以适应窗口,然后切换全尺寸并在单击时调整大小?

Javascript:调整图像大小以适应窗口,然后切换全尺寸并在单击时调整大小?,javascript,Javascript,我正在尝试创建一个小片段,以允许调整加载的图像以适应用户的分辨率。然后允许用户在实际图像大小和分辨率调整后的图像大小之间切换。以下是我目前得到的信息: <img src="<?=$file['direct_url']?>" border="0" onload="if(this.width>screen.width/1.5) {this.width=screen.width/1.5;this.alt='Click image to view full size';}wind

我正在尝试创建一个小片段,以允许调整加载的图像以适应用户的分辨率。然后允许用户在实际图像大小和分辨率调整后的图像大小之间切换。以下是我目前得到的信息:

<img src="<?=$file['direct_url']?>" border="0" onload="if(this.width>screen.width/1.5) {this.width=screen.width/1.5;this.alt='Click image to view full size';}window.status=this.width;" onmouseover="if(this.alt) this.style.cursor='hand';" onclick="if (this.width=screen.width/1.5) {this.width=screen.width*1.5} else {this.width=screen.width/1.5}">
“border=“0”onload=“if(this.width>screen.width/1.5){this.width=screen.width/1.5;this.alt='Click image to view full size';}window.status=this.width;“onmouseover=“if(this.alt)this.style.cursor='hand';“onclick=“如果(this.width=screen.width/1.5){this.width=screen.width*1.5}否则{this.width=screen.width/1.5}”>

非常感谢您的帮助!

我想您可能只需要一个自定义属性,将原始图像存储为/height

<img originalwidth="100" originalheight="100" />
this.getAttribute('originalwidth');
this.getAttribute('originalheight');