IE对img.width支持不好

来源:互联网 发布:淘宝浏览有什么好处 编辑:程序博客网 时间:2024/04/30 08:18

 
<script language="JavaScript">
<!--
function DrawImage(ImgD){
  var image=new Image();
  var iwidth = 500; 
//img.width支持不是很好,所以借助中间对象,且对src的支持好,有时alert(width)的支持会是o, 而alert(this.src)一定会是正确的值,而firFox绝对没有这个问题。
  image.src=ImgD.src;
  if(image.width>500){
    ImgD.width=iwidth; 
  }
}
</script>
<img src="1.jpg" style="CURSOR: pointer"  onload="DrawImage(this)" onclick="window.open(this.src)">

IE对这种就不稳定,有IE所获得的数据alert(width)有时会是o, 而firFox却不会
<IMG style="CURSOR: pointer" onclick=javascript:window.open(this.src);                   src="1.jpg"
                        onload="javascript:if(this.width>500){this.resized=true;this.style.width=500;}">

 

原创粉丝点击