怎么 在页面上 监听所有的浏览器原生的函数 比如说 alert这类的??


怎么 在页面上 监听所有的浏览器原生的函数 比如说 alert这类的??

原生js JavaScript

beargod 8 years, 6 months ago

 window.myalert = function () {
  document.dispatchEvent(new CustomEvent({ ..'beforeAlert' ...), ...);
  alert.apply(window, arguments);
}

document.addEventListener('beforeAlert', fn, ...)

myalert('hello')

欲望无限大 answered 8 years, 6 months ago

Your Answer