- IE不兼容版本:
直接采用iframe的srcdoc属性,把从pagesctrl读取的html内容(news_cnt参数)给srcdoc:
html:
<iframe id="myIframe" name="myIframe" width="100%" height="500" th:srcdoc="${news_cnt}" frameborder="0" scrolling="auto"></iframe>
但是srcdoc属性在IE浏览器(IE11)中并不支持,所以,探索另外的方法。
- IE兼容版本:
将news_cnt参数通过html传给js,再通过js进行html内容的展示:
html:
<iframe id="myIframe" name="myIframe" width="100%" height="500" style="border:none" scrolling="auto"></iframe>
<input type="hidden" id="news_cnt" name="news_cnt" th:value="${news_cnt}">
js:
var news_cnt = $("#news_cnt").val();
$('#myIframe').ready(function() {
var externalHtml = news_cnt;
$('#myIframe').contents().find('body').html('<div id="iframeContent">'+externalHtml+'</div>');
});