How to disabled alert function in javascript All In One
How to disabled alert function in javascript All In One
alert 阻塞主线程, js 改写原生方法
default ❌
alert;
// ƒ alert() { [native code] }
alert(`1`);
solution ✅
alert(`1`);
// alert: 1
// true
alert;
// ƒ (n){try{console.log("alert: "+n)}catch(t){}return!0}
window.alert = function(n){
try{
console.log("alert: "+n)
} catch(e){
// ignore
}
return !0;
}
!0 === true;
// true
customize alert
window.alert = function(n){
try{
console.log("alert =", n)
} catch(e){
// ignore
}
return `this is a changed alert!`;
}
alert(`1`);
// alert = 1
// "this is a changed alert!"
cnblogs
https://www.cnblogs.com/js/blog-common.min.js
demo
function a(){
var i=0;
function b(){
i++;
alert(i);
}
return b;
}
var c = a();
c();
// alert: 1
c();
// alert: 2
c();
// alert: 3
demos
(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!
refs
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/13410380.html
未经授权禁止转载,违者必究!