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