Try this:

if (typeof myFunction === "undefined") {
   $.getScript("myFunction.js", function() {
      alert('script loaded');
   });
}


--rob

On 7/20/07, Chrisss <[EMAIL PROTECTED]> wrote:


Hello,

I was wondering if jQuery can be used to load javascript dynamically,
on an as-needed basis. Here is the problem I have:

I want to load a page with as little javascript as possible. When
someone clicks on an item that requires some javascript functionality,
I want it to load a javascript function from an external file and then
execute it.

While there is some simple javascript I've found that can do this kind
of thing by appending the script to the DOM, it can't do things in
order. For instance, I want to load the function, and then execute it.
To do so, the javascript has to have some way to check if the funciton
exists. I don't like the idea of doing a time-out loop, so I was
wondering if jQuery has something built in for this kind of thing.

Thank you!
Chris




--
Rob Desbois
Eml: [EMAIL PROTECTED]
Tel: 01452 760631
Mob: 07946 705987
"There's a whale there's a whale there's a whale fish" he cried, and the
whale was in full view.
...Then ooh welcome. Ahhh. Ooh mug welcome.

Reply via email to