如果你是在父框架中使用iframe对象动态写入内容的话,请确保在写入vml脚本前,先将iframe内容初始化即写入
<HTML xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<style> v\:*{Behavior:url(#default#VML)}</style>
</head>
<body>
</body>
</html>
注:style那里的那个v要视你写vml标记的前缀而定了,比如如果你写的是<v:rect>

解决方案 »

  1.   

    iframe不是父框,我的意图是想做一个类似编辑器的东西,在页面上有一些控件,点按钮可以在页面上生成一些vml图形,我想把它改成通过点按钮在控件下面一点的iframe里生成vml图形,不知道这样的想法如何能实现?谢谢指教
      

  2.   

    的确有点特别,不过,建议你采用如下的方案,用两个页面来描述
    父a.html
    -----------------------------------------------------------------------
    <html>
    <script language=javascript>function drawLine()
    {
    frm1.drawLine();
    }
    </script>
    <body onload=init()>
    <input type=button value=画线 onclick=drawLine()><br>
    <iframe id=frm1 src=b.html style=width:300;height:300></iframe>
    </body>
    </html>
    -----------------------------------------------------------------------子页面b.html
    -------------------------------------------------------------------------
    <HTML xmlns:v=\"urn:schemas-microsoft-com:vml\">
    <head>
    <style> v\:*{Behavior:url(#default#VML)}</style><script language=javascript>
    function drawLine()
    {
    var s = "<v:line from=\"10,10\" to=\"50,50\"></v:line>";
    document.body.appendChild(document.createElement(s));
    }
    </script>
    </head>
    <body></body>
    </html>
    -------------------------------------------------------------------------