posts - 59,  comments - 323,  trackbacks - 0
            “吃藥”是一句上海話,就類似于“被晃掂”的意思。
           
            大家先看看這段代碼:
          <div id="a">
          </div>
          <script type="text/javascript">
          var node=document.createElement("div");
          node.setAttribute(
          "class","test");
          var tn=document.createTextNode("Test1");
          node.appendChild(tn);
          var a=document.getElementById("a");
          a.appendChild(node);
          </script>
            它在FireFox里能夠正確運行,一個class為test的div,被正確的顯示出來了。但是在IE里面,死活就是不行。
           
            后來我才知道,不能用setAttribute,而是得用setAttributeNode
           
          <div id="a">
          </div>
          <script type="text/javascript">
          var node=document.createElement("div");
          var attr=document.createAttribute("class");
          attr.value
          ="test";
          node.setAttributeNode(attr);
          var tn=document.createTextNode("Test1");
          node.appendChild(tn);
          var a=document.getElementById("a");
          a.appendChild(node);
          </script>

           

            犀牛書里是這么說的:“通常,用setAttribute()方法,比用setAttributeNode()簡單。但是,要為XML文檔定義一個性質包含實體引用的性質時,應該使用setAttributeNode()方法。

            什么叫XML文檔呀?什么叫性質包含實體引用的性質呀?反正我在IE里,搞搞HTML文檔,就是出不來,用了setAttributeNode,就成功了。

           

            所以,我“吃了犀牛書的藥”了。

          posted on 2006-01-25 01:23 讀書、思考、生活 閱讀(814) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2006年1月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          2930311234

          常用鏈接

          留言簿(20)

          隨筆檔案

          友情BLOG

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 翁源县| 安阳市| 蓝山县| 柳河县| 封开县| 皋兰县| 友谊县| 宜城市| 辉县市| 新巴尔虎右旗| 和龙市| 铁岭县| 忻州市| 乐东| 田东县| 安义县| 班玛县| 章丘市| 买车| 威海市| 汉中市| 宝山区| 彭山县| 特克斯县| 拜泉县| 武隆县| 板桥市| 马边| 顺平县| 崇明县| 泰宁县| 尤溪县| 萝北县| 宣化县| 新晃| 宜州市| 揭西县| 响水县| 连山| 深圳市| 孝义市|