当前位置: 移动技术网 > 移动技术>移动开发>IOS > IOS微信端confirm以及alert去掉网址的实例代码

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

2019年07月24日  | 移动技术网移动技术  | 我要评论

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网