您的位置:首页 > 移动开发 > 微信开发

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

2018-01-22 13:52 666 查看

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

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息