去掉网页中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(“你要弹出的东西”)即可。

 

相关文章:

  • 2022-12-23
  • 2021-09-19
  • 2022-01-23
  • 2021-10-18
  • 2022-12-23
  • 2021-05-22
猜你喜欢
  • 2022-12-23
  • 2021-09-02
  • 2021-10-25
  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
  • 2021-09-19
相关资源
相似解决方案