后台JSON在拉起支付的時候直接返回給我一段HTML代碼:
我需要在前端使用JS來完成HTML的編譯:
var win = window.open('', '運行窗口');
win.document.open();
win.document.write(yoursHTML);
win.document.close();
即可,但是只是這樣寫會有一個問題,在Safari瀏覽器打開后,還是無法拉起支付 有時還會報錯:
TypeError: Null Is Not an Object ,網上查是Safari瀏覽器內部機制阻止了window.open()
這個時候,我們需要做一些巧妙的操作,為了精准幫助其他人,精准搜索詞,具體請看下節。