隐藏网页中alert和confirm弹出框自带的网址

1、alert隐藏网址

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); 
}

2、confirm隐藏网址

window.confirm = function(message){ 
    var iframe = document.createElement("IFRAME"); 
    iframe.style.display="none"; 
    iframe.setAttribute("src", 'data:text/plain,'); 
    document.documentElement.appendChild(iframe); 
    var result = window.frames[0].window.confirm(message); 
    iframe.parentNode.removeChild(iframe);
    
    return result; 
}
原文地址:https://www.cnblogs.com/Dream2hc/p/web112836.html