Joseph Michael Pesch
VP Programming

JavaScript Add Function to Page Dynamically and Determine if Function Exists in Page

by 3. August 2010 23:49

// inject script file into page...

var jQueryScript = document.createElement('script');

jQueryScript.language = 'javascript';

jQueryScript.src = '/ISV/scripts/jquery-1.4.2.min.js';

// setup the event callback...

jQueryScript.onreadystatechange = function () {

  if (event.srcElement.readyState == "complete"

   || event.srcElement.readyState == "loaded")

  // call jQueryReady function only if it is declared in the page...

    if (eval("typeof jQueryReady == 'function'")) { jQueryReady(); }

}

// finally, attach the script file to the page...

document.getElementsByTagName('head')[0].appendChild(jQueryScript);

 

 

Tags:

[None]

Comments are closed