IOS微信端confirm以及alert去掉网址的实例代码

来自:互联网
时间:2020-05-26
阅读:

在做微信公众号开发时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去掉网址的实例代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

返回顶部
顶部