微信公众号h5页面alert去掉域名

h5页面内嵌到微信公众号提示信息alert的时候会显示域名,去掉域名显示重写alert方法:

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);
};
————————————————
版权声明:本文为CSDN博主「Zxiuping」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Zxiuping/article/details/90404271

猜你喜欢

转载自www.cnblogs.com/niudaxianren/p/12299000.html