Ian Richardson wrote:
<--snip-->
[color=blue]
>
>
> Again, this is "add something to the end of each file". It's not the
> approach I want as:
>
> a) Internet Explorer has it's own proprietary solution; i.e.
> periodically checking the readyState property. This works a treat for IE.[/color]
The AOL browser uses a shell of IE but you might want to be careful
trying to group it with IE as it does not provide all the functionality
that IE does. The first two that come to mind are the external and
onbeforeunload, IE supports both but AOL supports neither. Never tested
it to see whether it handles readystate the same as IE does or not.
I mention AOL because it has a very large user base and most people tend
to group it with IE but its not always safe to do that.
[color=blue]
> b) There simply must be a proper way of doing this using the DOM.[/color]
Not that I have ever found, that works reliably cross-browser.
[color=blue]
> I don't particularly want to go down the other kludge route of using the
> XMLHttpRequest object in Mozilla (and its activeX alternative in IE),
> then set the .text property of the script object I'm inserting into the
> HEAD of the document to the returned responseText string. The reason for
> this is the browser appears to freeze while it's fetching the resource.
>
> I've tried creating an object and then setting its .onload property, but
> this seems to be fired by Mozilla immediately rather than once the
> object is loaded.
>
> I should point out that my target browsers are latest versions of IE and
> Mozilla, and possibly Opera (now that 7.50 is half usable... but that's
> for another time!)
>
> Is there another solution?[/color]
Since you are including Opera 7 in the mix (I had originally considered
HTTPRequest as a possible solution but O7 doesn't support it at all)
then you are better off starting with O7 and making it work, then going
up the chain to Mozilla and then to IE.
This page:
<URL:
http://members.aol.com/justhikk/index.html >
works somewhat like you are implying yours does. Even if it doesn't, it
still has the same problem. How to know when the .js file is loaded.
Parts of it work, parts of it do not. It was something I was working on
2+ years ago and ran out of time to tinker with it anymore and have put
it on the shelf to work with on a later date.
Basically, what happens is every single menu item (with the exception of
the music menu) has a .js file associated with it that is nothing but
data. The functions are in the main page. You choose an option, it
loads the data file, then changes the page.
Change Option>Load JS File>Change Page.
The problem was "How to know when the JS file loaded so I could call the
function that changed the page" and in the end, the solution was very
simple. I put the function call at the end of the JS file.
Change Option>Load JS File>JS File Calls function>Function changes Page.
I honestly do not remember if that solution came to me on my own or if I
got it from this group. I beat my head on the same wall that you are
running into, needing to know when the file had finished loading, and
the simplest, most cross-browser method is indeed to append one or two
lines to each .js file and have the js file itself tell the main page
"Hey, Im loaded now", whether its via a variable, a function call or
some other method.
So please take it from my own experience and headaches that you aren't
going to find a cross-browser approach that works better.
Hope this helps.
PS The above page is the one that actually led to me making the page I
gave the URL for before:
<URL:
http://www.hikksworld.com/loadJSFiles/index.html >
Where I was trying to figure out how to even dynamically load the .js
file itself.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -
http://jibbering.com/faq/