web調用ios 失敗問題

在某些ios版本的app上,經過web 調用app存在失敗的想象,經過聯調
發現JSbridge 這個地方並無發送請求ios

var WVJBIframe = document.createElement('iframe');
        WVJBIframe.style.display = 'none';
        WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';

測試了好久,覺得是app緩存了iframe的請求形成的問題,
後來一想沒準iframe 延遲建立,再賦予 WVJBIframe.src值的時候是空的對象,並無負值成功
因此代碼追加了 setTime 測試正常了web

setTimeout(function(){
          WVJBIframe.style.display = 'none';
          WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
          document.documentElement.appendChild(WVJBIframe);
          setTimeout(function () {
              document.documentElement.removeChild(WVJBIframe)
          }, 0);
          sessionStorage.phoneType = 'ios'
        },100)

此問題只在部分系統版本中出現,大部分沒有問題。緩存

相關文章
相關標籤/搜索