在做微信公眾號開發時IOS端的微信瀏覽器打開,觸發confirm以及alert時彈出框會有附帶當前網址信息,Android端的沒有測試,不知道是否有同樣的情況。
解決辦法如下:
“`window.alert = function(name){ var iframe = document.createElement("IFRAME"); iframe.style.display="none"; iframe.setAttribute("src", 'data:text/plain,'); document.documentElement.appendChild(iframe); window.frames[0].window.alert(name); iframe.parentNode.removeChild(iframe); }; window.confirm = function (message) { var iframe = document.createElement("IFRAME"); iframe.style.display = "none"; iframe.setAttribute("src", 'data:text/plain,'); document.documentElement.appendChild(iframe); var alertFrame = window.frames[0]; var result = alertFrame.window.confirm(message); iframe.parentNode.removeChild(iframe); return result; }; alert('abc'); confirm('are you sure?');“`
以上這篇IOS微信端confirm以及alert去掉網址的實例代碼就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持VEVB武林網。
新聞熱點
疑難解答