![自定义alert弹框,title不显示域名 自定义alert弹框,title不显示域名](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
问题: 系统默认的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('试一试');