使用IE 8,我試圖通過javascript在頁面上添加兩個VML橢圓(A,B)。無論將哪個橢圓添加到父DIV中,都會呈現,但第二個不是。在IE8中通過JavaScript添加多個VML元素
如果我appendChild(A)然後appendChild(B),呈現橢圓形A,B不是。 如果我appendChild(B)然後appendChild(A),呈現橢圓形B,A不是。
document.namespaces.add("v","urn:schemas-microsoft-com:vml");
this.container = Document.getElementById(mydiv);
var grid2 = document.createElement("v:oval");
grid2.style.left= "300px";
grid2.style.top= "250px";
grid2.style.width= "25pt";
grid2.style.height= "75pt";
grid2.style.position="absolute";
grid2.style.behavior="url(#default#VML)";
grid2.style.display="inline-block";
grid2.setAttribute("fillcolor","#FF0000");
grid2.setAttribute("id", "marker2");
var grid = document.createElement("v:oval");
grid.style.left="100px";
grid.style.top="100px";
grid.style.width="94pt";
grid.style.height="164pt";
grid.style.position="absolute";
grid.style.behavior="url(#default#VML)";
grid.style.display="inline-block";
grid.setAttribute("fillcolor","#0000FF");
grid.setAttribute("id", "marker");
this.container.appendChild(grid2);
this.container.appendChild(grid);
我錯過了添加VML的一些技巧嗎?
我已經在IE 9中試過了,結果相同。
由於公司規則,公司內部只支持IE,許多用戶仍在使用IE8,所以目前我無法切換HTML5 Canvas。
感謝您的任何建議
爲什麼不使用[Raphaël](http://raphaeljs.com/)?這有一個*多*清潔API;並將使用VML for IE(和其他瀏覽器的SVG),所以你將有IE支持。 – vcsjones
什麼是HTML頁面的文檔類型,這使得在IE中渲染VML有一個重要的區別? – David
我已經開始看拉斐爾圖書館,它看起來很有希望。至於DOCTYPE,我會驗證我的。大衛,你說的對,根據我的經驗,IE對DOCTYPE和其他瀏覽器更爲敏感。感謝您的快速建議。 –