js里面如何获取网络地址的图片的高度和宽度 (变通办法)

原图片是 :<img src=”http://gg.blueidea.com/2008/blueidea/flash2008.gif”>

<div id=”box”></div>

<script language=”javascript”>
(function(){
var img=document.createElement(‘img’);//创建一个img元素
img.src=”http://gg.blueidea.com/2008/blueidea/flash2008.gif”;//指定src
img.style.position=”absolute”;//防止正常的内容变形
img.style.visibility=’hidden’;//藏起来
var inj=document.getElementById(‘box’).appendChild(img);//插入到box中。当然插入到document.body也可以
alert(‘宽:’+inj.offsetWidth);//然后就可以通过 offset 取得宽和高了
alert(‘高:’+inj.offsetHeight);
})();
</script>

简单地说就是把图片放入一个自动伸缩的DIV中,然后获取DIV的宽和高!

33 thoughts on “js里面如何获取网络地址的图片的高度和宽度 (变通办法)

  1. Pingback: NEWB Review

  2. Pingback: 메이저사이트

  3. Pingback: w88

  4. Pingback: 카지노사이트

  5. Pingback: w88 thailand

  6. Pingback: forum

  7. Pingback: uniccshop.mn

  8. Pingback: dang ky fun88

  9. Pingback: หวยเด็ด

  10. Pingback: Renewable Energy Company

  11. Pingback: porn

  12. Pingback: Free Bets

  13. Pingback: Personalized Cornhole Boards

  14. Pingback: dominoqq

  15. Pingback: https://sportzdrowie.com.pl/forum/zele-masci-plastry-f15/paski-crest-pl-opinie-t408.html

  16. Pingback: porn

  17. Pingback: 조커바카라사이트

  18. Pingback: how to steal a bycicle

  19. Pingback: how to buy firearms in europe

  20. Pingback: 바카라 사이트 신고

  21. Pingback: THC vape pens

  22. Pingback: Library

  23. Pingback: 오피녀

  24. Pingback: Medium Mireille

  25. Pingback: Tess ter Horst

  26. Pingback: 바카라사이트

  27. Pingback: Arthur touched 롤대리사이트 at New Hampshire after 롤 커뮤니티 now.

  28. Pingback: corey zieman reviews

  29. Pingback: careprost

  30. Pingback: 4solarpanels.info

  31. Pingback: optional health care viagra abortion

  32. Pingback: akc english bulldog puppies for sale in georgia

  33. Pingback: keto diet review

Leave a Reply