IOS微信端confirm以及alert去掉网址的示例分析

这篇文章给大家分享的是有关IOS微信端confirm以及alert去掉网址的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

在做微信公众号开发时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去掉网址的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!