阅读:8044回复:9
js+dom中在不同浏览器的区别
我这段时间都在写js+dom的代码,不知道有什么实用一点的文章。
如果可以的话,大家都可以把自己知道的区别写上来,让我们可以写出兼容性好的代码。 我先写几个,如果有新的我就加在后面。 1. childNodes在ff中和ie的区别。 ff中的node(nodeType = 1)都是用textNode(nodeType = 3)分开的,而ie/op不是这样的。 <div id="box1"><span>content</span></div> 在ff下,box1的childNodes为3个,ie下为1个。 2. 设置某个node对象的style class名称。 ie中要设置某个node的class用"className"作为attr来set或者get。 ff等其它的浏览器用"class"作为attr来set或者get。 if(typeof node1.getAttribute("className") == "string") { .... } 3. 设置某个node对象的style content。 直接举例把 var oStyle = oNode.getAttribute("style"); // ie if(oStyle == "[object]") { oStyle.setAttribute("cssText", strStyle); oNode.setAttribute("style", oStyle); } else { oNode.setAttribute("style", strStyle); } 4. 事件对象。 ie用event ff用evnt 5. 事件作用对象 ie用objEvent.srcElement ff用objEvent.target 大家有新的就补充一下吧,我目前写得js代码不多,就这点内容。 希望这个帖子对我这样的初级开发者能实用~ |
|
|
1楼#
发布于:2005-05-18 18:01
谢谢说明,我对ie的xml开发包不熟悉。
softcup: |
|
|
2楼#
发布于:2005-05-18 18:01
|
|
|