Stop window.location in a global context

I want to stop window.location from executing as shown below when the page loads:

<script type="text/javascript"> alert('Bid closed '); window.location = '/index.html'; </script> 

I can get around the alert message by replacing the alert function during document_start in manifest.json. But failed to stop window.location from execution.

+5
source share
2 answers

The answer looks the same as a math puzzle.

In the script I entered, I just posted this code and it seems to work:

 window.alert = function (msg) { throw Error('hello'); } 

This exception causes the browser to skip the following window.location= statement

0
source

window object is not writable, so you cannot modify document objects and window check this link for more information

+2
source

Source: https://habr.com/ru/post/1266253/


All Articles