去掉网页中alert和confirm弹出框自带的网址

去掉网页中alert和confirm弹出框自带的网址
Alert:


<script>
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('xxx');
</script>

 

Confirm:

 

<script>
window.confirm = function(message){
var iframe = document.createElement("IFRAME");
iframe.style.display="none";
iframe.setAttribute("src", 'data:text/plain,');
document.documentElement.appendChild(iframe);
window.frames[0].window.confirm(message);
iframe.parentNode.removeChild(iframe);

var result = window.frames[0].window.confirm(message);
iframe.parentNode.removeChild(iframe);
return result;
}

confirm('xxx');

</script>

使用方法简单引用以上代码直接使用alert(“你要弹出的东西”)即可。

 

posted @ 2017-02-22 16:38  小白的进阶之路  阅读(1369)  评论(0编辑  收藏  举报