2012-07-06 40 views
0

这是一个非常简单的VML示例,它在所有版本的IE上都可以很好地显示。它还打印在除IE8以外的所有版本的IE上。我知道有可能让IE8打印VML,但无法找到我应该怎么做。感谢您的任何提示。在IE8中打印VML

<script type="text/javascript"> 

     window.onload = function() 
     { 

      document.createStyleSheet().cssText = 'v\\:oval { behavior:url(#default#VML); display: inline-block}';        
      document.namespaces.add('v', 'urn:schemas-microsoft-com:vml'); 

      var node = document.createElement("<v:oval>"); 
      node.style.width = "100px"; 
      node.style.height = "100px";     
      document.getElementById("mydiv").appendChild(node); 
     } 

    </script> 

    <div id="mydiv" style="background-color:#eeeeee; width: 800px; height: 620px;"> 
+0

我注意到,在所有的修复去除文档类型这个问题,但它不是一个很好的解决方案,因为我被广泛使用... – zeroin 2012-07-06 11:22:33

回答

0

您必须添加第三个参数document.namespaces.add:

document.namespaces.add('v', 'urn:schemas-microsoft-com:vml', '#default#VML');