后端返回html字符串 样式覆盖全局必须用 iframe嵌套显示才行
$.axios({
method: "POST",
url: progressUrl,
data: params,
async: false,
success: function (res) {
if (res.code == 200) {
var htmlData = res.data || '';//html字符串
div.html('<iframe id="iframe" class="surgerAnesthIframe" src=""></iframe>');
var iframeDom = document.getElementById('iframe');
// iframeDom.contentWindow.document.body.innerHTML = htmlData;
这里是测试数据
;iframeDom.contentWindow.document.body.innerHTML = '<!DOCTYPE html>\n <html moznomarginboxes mozdisallowselectionprint>\n <head>\n <style>\n html, body {\n margin: 0;\n width: 793.8px;\n height: 1122.6px;\n }\n </style>\n </head>\n <script>(function() { window.ready = true; })();</script>\n <body> <div style="width: 100px;height:100px;color:red;">你好世界</div> </body>\n </html>'
_t.iframeBoxHeight();
}
}
});