在做微信公众号开发时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去掉网址的实例代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
Codeforces Round #657 (Div. 2) C题
hdu2222 Keywords Search(ac自动机模板-kuangbin)
IOS开发控件视图day08:监听文本框状态设置按钮状态不可点击且变灰
网友评论