自定義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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM