1. childNodes在ff中和ie的區(qū)別。
ff中的node(nodeType = 1)都是用textNode(nodeType = 3)分開的,而ie/op不是這樣的。
<div id="box1"><span>content</span></div>
在ff下,box1的childNodes為3個(gè),ie下為1個(gè)。
2. 設(shè)置某個(gè)node對(duì)象的style class名稱。
ie中要設(shè)置某個(gè)node的class用"className"作為attr來set或者get。
ff等其它的瀏覽器用"class"作為attr來set或者get。
代碼: |
if(typeof node1.getAttribute("className") == "string") { .... } |
3. 設(shè)置某個(gè)node對(duì)象的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. 事件對(duì)象。
ie用event
ff用evnt
5. 事件作用對(duì)象
ie用objEvent.srcElement
ff用objEvent.target
這個(gè)跟 xml 文件寫作有關(guān),將 IE 的 preserveWhiteSpace 設(shè)為 true 看看,底下是取自微軟的說明文件
代碼: |
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0"); xmlDoc.async = false; xmlDoc.preserveWhiteSpace = true; xmlDoc.load("books.xml"); alert(xmlDoc.xml); xmlDoc.async = false; xmlDoc.preserveWhiteSpace = false; xmlDoc.load("books.xml"); alert(xmlDoc.xml); |