后台返回完整的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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM