Gerard Yin
Gerard Yin

Reputation: 1313

Disable one bit of Javascript in a page

Not actually, about programming, but more about programming tools (Firebug, Chrome Developer Tool). I understand from the FAQ that this is ok here. I am stumbling on a legacy redirect in one of our HTML pages, and cannot get rid of it, neither with Chrome Developer Tools, nor Firebug. This is this bit of inline code, inserted in the HTML file body:

<SCRIPT type=text/javascript><!--
Redirect();
function Redirect()
{
location.href = 'https://another/page/';
}
// --></SCRIPT>

Unfortunately, I don't have access to this page's source. I want to avoid the execution of this snippet, while keeping all the rest of Javascript active. The goal is simply to change the redirection URL, by accessing some admin controls that need Javascript to work! (I know we put ourselves in a big mess...)

I tried to use the most of the Chrome Developer Tools/Firebug to get me out of this, but may be lacking experience with them. What I tried: Set a breakpoint with Firebug on the location.href = ... line. Unfortunately, both Firebug and Chrome Developer Tool keeps all Javascript execution frozen during the breakpoint. There's AFAK no option to cancel the location.href = execution while retaining other Javascript code active, patch the code, or to use the admin panels meanwhile. I also investigated greasemonkey's behavior, but don't see any obvious way to make it work for me here.

Upvotes: 1

Views: 210

Answers (1)

Chakradhar Vyza
Chakradhar Vyza

Reputation: 285

Try overriding the method in your html page and see if it works

function Redirect()
{
location.href = 'https://another/page/';
}

with function Redirect() {

}

Hope I helped

Upvotes: 1

Related Questions