JS代码怎么获取指定路径图片的大小
若以下回答无法解决问题,邀请你更新回答
展开全部
HTML>
<HEAD>
<SCRIPT>
function getImageDimension (imgURL, loadHandler) {
var img = new Image();
img.onload = loadHandler;
img.src = imgURL;
}
function showImageDimensions () {
if(this.width>200 && this.height>100) {
alert(this.width + 'x' + this.height+"\n"+"5");
} else {
alert("taixiao");
}
}
</SCRIPT>
<SCRIPT>
function checkImageDimensions (fileName) {
var imgURL = 'file:///' + fileName;
getImageDimension(imgURL, showImageDimensions);
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="formName">
<INPUT TYPE="file" NAME="fileName">
<BR>
<INPUT TYPE="button" VALUE="check image dimensions"
ONCLICK="checkImageDimensions(this.form.fileName.value)">
</FORM>
</BODY>
</HTML>
<HEAD>
<SCRIPT>
function getImageDimension (imgURL, loadHandler) {
var img = new Image();
img.onload = loadHandler;
img.src = imgURL;
}
function showImageDimensions () {
if(this.width>200 && this.height>100) {
alert(this.width + 'x' + this.height+"\n"+"5");
} else {
alert("taixiao");
}
}
</SCRIPT>
<SCRIPT>
function checkImageDimensions (fileName) {
var imgURL = 'file:///' + fileName;
getImageDimension(imgURL, showImageDimensions);
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="formName">
<INPUT TYPE="file" NAME="fileName">
<BR>
<INPUT TYPE="button" VALUE="check image dimensions"
ONCLICK="checkImageDimensions(this.form.fileName.value)">
</FORM>
</BODY>
</HTML>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询