js兼容火狐获取图片宽和高的方法
作者:bea
本文实例讲述了js兼容火狐获取图片宽和高的方法。分享给大家供大家参考。具体实现方法如下: <!doctype html> <html> <head> <meta content="text/html; charset=GBK" http-equiv="Content-Type" /> <title>获取Image 宽高</title></head> <body><scri
本文实例讲述了js兼容火狐获取图片宽和高的方法。分享给大家供大家参考。具体实现方法如下:
<!doctype html>
<html>
<head>
<meta content="text/html; charset=GBK" http-equiv="Content-Type" />
<title>获取Image 宽高</title>
</head>
<body>
<script>
function newimage(obj) {
a = new Image();
var objectURL = window.URL.createObjectURL(obj.files[0]);
var img= document.getElementById('img')
img.src = objectURL;
a.src = objectURL;
img.onload=function (){
alert(img.width);
alert(img.height);
}
}
</script>
<input id="idcardfile" type="file" name="idcardfile"
onchange="newimage(this)"/>
<img id="img" style="display: none;">
</body>
</html>
希望本文所述对大家的javascript程序设计有所帮助。
有用 | 无用
<!doctype html>
<html>
<head>
<meta content="text/html; charset=GBK" http-equiv="Content-Type" />
<title>获取Image 宽高</title>
</head>
<body>
<script>
function newimage(obj) {
a = new Image();
var objectURL = window.URL.createObjectURL(obj.files[0]);
var img= document.getElementById('img')
img.src = objectURL;
a.src = objectURL;
img.onload=function (){
alert(img.width);
alert(img.height);
}
}
</script>
<input id="idcardfile" type="file" name="idcardfile"
onchange="newimage(this)"/>
<img id="img" style="display: none;">
</body>
</html>
希望本文所述对大家的javascript程序设计有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 微信内置浏览器私有接口WeixinJSBridge介绍
- 微信浏览器内置JavaScript对象WeixinJSBridge使用实例
- JS中的THIS和WINDOW.EVENT.SRCELEMENT详解
- jQuery实现表格行上移下移和置顶的方法
- jquery控制表单输入框显示默认值的方法
- jQuery实现自动滚动到页面顶端的方法
- JavaScript检测鼠标移动方向的方法
- jQuery实现强制cookie过期方法汇总
- jQuery判断指定id的对象是否存在的方法
- jQuery实现转动随机数抽奖效果的方法
- JQuery分屏指示器图片轮换效果实例
- jQuery聚合函数实例
- js获取页面description的方法
- js同源策略详解
- js设置document.domain实现跨域的注意点分析
- jQuery+ajax实现无刷新级联菜单示例
- jQuery插件expander实现图片翻转特效
- 简单分析javascript面向对象与原型
- jQuery获取上传文件的名称的正则表达式