后台返回完整的HTML页面代码,如何打开展示

问题:

后台返回的html代码片段,需要插入html标签中,而返回的整个html文档,则需要重写整个页面。

解决方法:

1.需要一个中转页面,用document.write()方法重写整个页面;
// POST任意内容并跳转
function StandardPost(html) {
    localStorage.removeItem('callbackHTML');
    localStorage.setItem('callbackHTML',html);
    window.location.href = window.location.href.split('/h5/')[0] + '/h5/callBack.html';
}
2.callBack.html 页面:
<script>
    document.write(localStorage.getItem('callbackHTML'));
    document.close();
</script>
posted @ 2019-05-29 13:35  missme_lina  阅读(11935)  评论(0编辑  收藏  举报
喜欢就“全力以赴”,不对盘就“在下告辞”,原则是“可以辛苦,但不能委屈”。