![](/img/trans.png)
[英]Prevent iOS web app w/ redirect from opening link in mobile Safari
[英]Completely prevent iOS web app from opening link in mobile Safari, even with links containing parameters
我發現了多種解決方案來防止iOS Web應用程序在移動Safari中打開常規鏈接,但不幸的是,它們不適用於包含參數的鏈接,例如
href="index.php?s=example"
這些仍在移動Safari中打開。
到目前為止,我在普通堆棧中找到的最短解決方案可以在stackoverflow上找到。 也許有人可以修改該腳本?
嘗試4歲的github gist 。 我用它,它的工作原理。 您可以通過bower
使用它:
涼亭安裝-保存iosweblinks
可能是頁面上出現javascript錯誤,並且處理程序無法調用?
PS我修改的腳本,用於防止以standalone
模式在Safari中打開鏈接:
(function (standalone) {
if (!standalone) {
return;
}
document.addEventListener('click', function (e) {
var element = e.target,
href = '';
while (!/^(a|html)$/i.test(element.nodeName)) {
element = element.parentNode;
}
if (element.getAttribute) {
href = element.getAttribute('href');
if ('' !== href && '#' !== href && null !== href && (!element.protocol || element.protocol !== 'tel:')) {
e.preventDefault();
window.location = element.href;
}
}
}, false);
}(window.navigator.standalone));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.