日期:2014-05-17  浏览次数:20427 次

iframe 动态连接 .mht
1. 单独在浏览器中查看 Template_V10.mht文件正常显示(该文件由excel另存成的)
2. 通过js把它加载到iframe中,有的浏览器无内容显示,有的浏览器提示“下载”
目标:通过js动态把.mht文件加载到iframe中

主要代码如下:
<body>
    <button onclick="asd()"></button>
            <div title="mht">
                <iframe  style="POSITION: absolute;z-index: -1; width:100%;height:100%;" id="DivReport3"
                    ></iframe>
            </div>
</body>
</html>
<script type="text/javascript">
    function asd() {
        var ifra = document.getElementById("DivReport3");
        ifra.src = "Template_V10.mht";
    }
</script>
iframe?js?mht

------解决方案--------------------
只有ie支持mht,其他浏览器都不是完全支持或需要插件。
http://en.wikipedia.org/wiki/MHTML

------解决方案--------------------
在ifram里面添加一个 src=""
------解决方案--------------------
<body>
    <button onclick="asd()"></button>
            <div title="mht" id="mhtFrame">
                <iframe  style="POSITION: absolute;z-index: -1; width:100%;height:100%;" id="DivReport3"
                    ></iframe>
            </div>
</body>
</html>
<script type="text/javascript">
    function asd() {
        var div = document.getElementById("mhtFrame");