用jquery来判断比较好了或者你先判断浏览器是否支持再写代码

解决方案 »

  1.   

    <html>
    <head>
    <title></title>
    </head>
    <body>
    <form id="formid" action="index.html">
    <input name="aa" id="aa">
    <input type="button" name="qq" id="qq" onclick="test1()"  value="test">

    </form>
    </body>
    </html>
    <script>
    function test1()
    {
     var aaa = document.getElementById("aa");
     for(i in aaa)
     {
      if(i=='id')
      {
      alert("有id属性");
      break;
      }
     
      }
    }</script>
    用这个
      

  2.   

    看这:https://developer.mozilla.org/Talk:En/DOM/Element.getAttribute
    Firefox and Safari both return null when the attribute is inexistent or missing.
    Internet Explorer 6's behavior is unfortunately a little more erratic.
    Opera conformed to the specs until version 9 which also returns null. 
      

  3.   

    <input caiying2009="a" value="b" id=ttt> 
    <script language="javascript">
    <!--
    var element=document.getElementById("ttt")
    alert(typeof(element.caiying2009))
    alert(element.getAttribute("caiying2009"))
    //-->
    </script>ie6-ok