問題:ios封裝完之后,點擊里邊的按鈕會跳轉到網頁上
——小卡遇到這個問題就是這樣解決的↓↓↓
解決方法:建議將代碼放到</head>
標簽前,當然,另外存為一個js 文件引用也是可以的呦~
<script type="text/javascript"> //iOS Web APP中點擊鏈接跳轉到Safari 瀏覽器新標簽頁的問題 devework.com //stanislav.it/how-to-prevent-ios-standalone-mode-web-apps-from-opening-links-in-safari if(("standalone" in window.navigator) && window.navigator.standalone){ var noddy, remotes = false; document.addEventListener('click', function(event) { noddy = event.target; while(noddy.nodeName !== "A" && noddy.nodeName !== "HTML") { noddy = noddy.parentNode; } if('href' in noddy && noddy.href.indexOf('http') !== -1 && (noddy.href.indexOf(document.location.host) !== -1 || remotes)) { event.preventDefault(); document.location.href = noddy.href; } },false); } </script>