Biff MaGriff
Biff MaGriff

Reputation: 8231

How do I override a javascript function that is inside another file?

I am having a problem with the asp:Menu control.
A menu control 2 levels deep does not play well with internet explorer on https.
I continually get an annoying popup.

I think in order to fix this I need to override a function in an automatically included script file.

change this

function PopOut_Show(panelId, hideScrollers, data) {
...
childFrame.src = (data.iframeUrl ? data.iframeUrl : "about:blank");
...
}

to this

function PopOut_Show(panelId, hideScrollers, data) {
...
if(data.iframeUrl)
childFrame.src = data.iframeUrl;
...
}

however I have no clue how I would hack apart the asp:menu control to fix microsoft's javascript in their control.

Is there a way I can just override the function to what I need it to be?

Upvotes: 2

Views: 5615

Answers (2)

gen_Eric
gen_Eric

Reputation: 227240

childFrame.src = (data.iframeUrl ? data.iframeUrl : "about:blank");

Is identical to:

if(data.iframeUrl){
    childFrame.src = data.iframeUrl;
}
else{
    childFrame.src = 'about:blank';
}

Why do you need to override the function?

Upvotes: 0

Alex Rashkov
Alex Rashkov

Reputation: 10015

If you declare the overload later that should be the function that executes

function alerttest(){
alert("1");
}

function alerttest(){
alert("2");
}

alerttest();

Here is another answer: Overriding a JavaScript function while referencing the original

Upvotes: 3

Related Questions