問題: 系統默認的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('試一試');