Let's say a web page did this:
window.alert = console.info;
How can I, through browser console, recover the original alert
method to get the modal back?
I tried accessing the window.prototype
but it does not exist. I would also like to know if such process exist in general (like, if String.*
was erased/redefined by a website or if website made a console.log = window.alert
).
Another reason not to use document. write() is it doesn't support XHTML, but its not an issue since most web development uses HTML. Since document. write() fires after a page has finish loading, it causes performance issues and sometimes, may not even fire at all.
write after the document has loaded, it overwrites the entire document. If it is run before that, it does not overwrite it.
What you can do, is create an iframe attach it to page and then copy alert method from that iframe
//someone did this
window.alert = null;
//you are doing this
var frame = document.createElement('iframe');
document.body.appendChild(frame);
window.alert = frame.contentWindow.alert.bind(window);
document.body.removeChild(frame);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With