PDA

View Full Version : Calling inserted JS functions


ChiefRB
08-12-2002, 02:17 PM
Hey guys and girls,

Ok, I've done a few searches of the forum and came up with nothing. Perhaps that's because this is a kind of multilanguage question.

Here's the situation - I'm writing a Browser Helper Object that inserts some JS on the end of each page the browser views. This can only be done once the DocumentComplete event has fired, so all page processing via the browser has finished.

I have managed to get script to run by embedding it within onClick events of various HTML elements, then calling the event handler, but this isn't quite sophisticated enough - what I really want to do is load up an external JS file.

Is there any part of the DOM that can call a function directly, or is there any way to refresh only a portion of the page?

Barring all that, does anyone have any other suggestions as to what I might try?

ChiefRB
08-12-2002, 08:05 PM
Just a small *bump*... :)

Roy Sinclair
08-12-2002, 09:15 PM
What you want is as clear as mud, perhaps if you rephrased it?

ChiefRB
08-12-2002, 09:24 PM
Sure.. :)

I've inserted some JS code into a webpage after the page has finished loading (eg, after the <BODY> onLoad event has finished).

As such, this code is not recognised by the browser, so is there any way to tell the browser that its there, or invoke it somehow?

Roy Sinclair
08-12-2002, 09:38 PM
Originally posted by ChiefRB
Sure.. :)

I've inserted some JS code into a webpage after the page has finished loading (eg, after the <BODY> onLoad event has finished).

As such, this code is not recognised by the browser, so is there any way to tell the browser that its there, or invoke it somehow?

Are you saying you're using the onload event to add an additional script to the page? Theoretically such a script could simply call itself as it's loaded:


function postLoad()
{
alert('This code is running')
}
postLoad();


Code not in a function declaration should be run as the browser processes it.

ChiefRB
08-12-2002, 09:45 PM
No, I'm not adding in the onLoad. I'm using an external ActiveX control to add once the browser has completely finished rendering the page, this includes processing all scripts.

Roy Sinclair
08-12-2002, 09:49 PM
Originally posted by ChiefRB
No, I'm not adding in the onLoad. I'm using an external ActiveX control to add once the browser has completely finished rendering the page, this includes processing all scripts.

That definitely puts you outside any experience I've had trying to do "odd" things.

ChiefRB
08-12-2002, 09:49 PM
Ah well... Thanks :)