📄 img-auto-size.js
字号:
function img_auto_size(oldimg,maxSize,openNewWindow){
var newimg = new Image();
newimg.src = oldimg.src;
if (newimg.width > 0 && newimg.height > 0) {
if (newimg.width > maxSize){
oldimg.width = maxSize;
oldimg.height = (newimg.height * maxSize) / newimg.width;
oldimg.onmouseover = function() {
this.style.cursor= "hand";
};
oldimg.onmouseout = function() {
this.style.cursor="";
};
if(openNewWindow){
oldimg.onclick = function() {
window.open(this.src, '_blank');
};
}
} else {
oldimg.width = newimg.width;
oldimg.height = newimg.height;
}
//oldimg.alt = "点击查看原始大小 " + newimg.width + " x " + newimg.height;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -