自定义alert弹框,title不显示域名(重写alert)

问题: 系统默认的alert弹框的title会默认显示网页域名
解决办法:
(修改弹框样式)
(function() {
window.alert = function(name) {
$(".tip").css("display", "block")
$(".tip .content").html(name)
}
})()

调用:alert(name)
在页面中添加弹框元素,自定义其样式,默认隐藏
注:alert()方法重写,不能传多余参数
(仅去掉网址)

 

(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);
}
})();
alert('试一试');

转: https://www.cnblogs.com/lvshuya/p/6549525.html

原文地址:https://www.cnblogs.com/fps2tao/p/11645807.html