img没有empty属性吧可能是自己设的属性,以作判断

解决方案 »

  1.   

    如果是自己添中的属性。那为什么我下面的代码会出错?(myNum是我随意添加的一个属性)
    Untitled-5.js:// JavaScript Document
    function Test()
    {
    var tempImage=new Image();
    }
    Test.prototype.Set=function()
    {
    this.tempImage.myNum=0;
    }
    Test.prototype.Click=function()
    {
    this.Set();
    alert(this.tempImage.myNum);
    }
    Untitled-4.html:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript" src="Untitled-5.js"></script>
    <script language="javascript">
    InsTest=new Test();
    </script>
    </head><body>
    <div id="aa" style="position:absolute; left:10px; top:10px; widows:400px; height:300px; background-color:#FF99FF" onclick="InsTest.Click();">TEST</div>
    </body>
    </html>
      

  2.   

    Try: var tempImage=new Image();
    ==>
    this.tempImage=new Image();
      

  3.   

    ls正解
    tempImage undefined