Home > Web Front-end > JS Tutorial > body text

js compatible Firefox method to obtain image width and height_javascript skills

WBOY
Release: 2016-05-16 15:58:00
Original
1010 people have browsed it

The example in this article describes the method of obtaining the image width and height using js compatible with Firefox. Share it with everyone for your reference. The specific implementation method is as follows:

<!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>

Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!