Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Break javascript before an inline javascript redirect in Chrome

I'm viewing a page that has an inline javascript redirect (window.location = "/anotherpage"). I want to load the page in Chrome but have the redirect line disabled, so I can use the page without getting redirected away.

Here's what I've tried:

  • Developer tools -> Cog -> General -> Disable JavaScript. Load the page. It doesn't redirect (yay!). But I still want the rest of the page's javascript to run, and it hasn't.

  • Type the URL, then click Developer tools -> Sources -> Pause (F8) real fast! It hasn't redirected yet (yay!) Now I want to disable the redirect line before unpausing, but that part hasn't even loaded yet into Developer Tools. So I'll start stepping through the other files javascript code until I get there?? But as soon as I step out of the other files javascript, it immediately redirects away (doh!).

Can this be done? I thought it should be easy to disable a line of javascript, but I'm stumped.

like image 749
krubo Avatar asked Sep 10 '12 22:09

krubo


People also ask

How do I stop JavaScript from redirecting?

In that case, the new page can use JavaScript to redirect our article to a phishing page asking for BleepingComputer credentials. To prevent this from happening, a rel="noopener" HTML link attribute was created that prevents a new tab from using JavaScript to redirect the page.

How do I stop JavaScript execution in Chrome?

Open Chrome DevTools. Press Control+Shift+P or Command+Shift+P (Mac) to open the Command Menu. Start typing javascript , select Disable JavaScript, and then press Enter to run the command. JavaScript is now disabled.

Can you redirect a page to another page using JavaScript How?

It is quite simple to do a page redirect using JavaScript at client side. To redirect your site visitors to a new page, you just need to add a line in your head section as follows.


1 Answers

Developer Tools -> Sources -> Event Listener Breakpoints (on the right sidebar) -> Load -> check unload

This will make debugger break on unload event which is dispatched before navigation.

like image 124
vsevik Avatar answered Oct 21 '22 11:10

vsevik