(function() {
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);
}
})();
H5去掉alart弹框提示浏览器默认加网址
最新推荐文章于 2024-02-27 16:25:25 发布
这篇博客揭示了一种在JavaScript中创建隐藏IFRAME并利用其window对象来实现alert弹窗的方法。通过动态创建IFRAME元素,设置其src为data:text/plain,然后将IFRAME插入到文档中,再利用window.frames[0]调用alert函数,最后移除IFRAME。这种方法可能在某些特定场景下用于避免alert被阻止或者修改alert的行为。
摘要由CSDN通过智能技术生成