后台返回的html代碼片段,需要插入html標簽中,而返回的整個html文檔,則需要重寫整個頁面。
解決方法:
需要一個中轉頁面,用document.write()方法重寫整個頁面;
-
// POST任意內容並跳轉
-
function StandardPost(html) {
-
localStorage.removeItem(
'callbackHTML');
-
localStorage.setItem(
'callbackHTML',html);
-
window.location.href =
window.location.href.split(
'/pages/')[
0] +
'/pages/account/call_back.html';
-
}
call_back.html 頁面:
-
<script>
-
document.write(localStorage.getItem(
'callbackHTML'));
-
document.close();
-
</script>