隐藏网页中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; 
}

 

posted @ 2020-11-05 09:18  hcha0  阅读(1273)  评论(1编辑  收藏  举报