65、点击图片获得信息

65、点击图片获得信息

脚本说明:

把如下代码加入<body>区域中

<img src="ps.gif" width=200 height=80

  onclick=alert('图片原始宽度为:'+GetImageWidth(this)+'\n图片原始高度为:'+GetImageHeight(this))>

<script>

var OriginImage=new Image();

function GetImageWidth(oImage)

{

  if(OriginImage.src!=oImage.src)OriginImage.src=oImage.src;

  return OriginImage.width;

}

function GetImageHeight(oImage)

{

  if(OriginImage.src!=oImage.src)OriginImage.src=oImage.src;

  return OriginImage.height;

}

</script>

 

Write a comment

Comments: 0