問題:
后台返回的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>