cali_oo7
asked on
javascript concurrency issue
i am having a problem with javascript continuing to process before a function is completed.
what i am trying to do is call the following function to include a .js file so that its functions will be available to my program.
function include_dom(script_filenam e) {
var html_doc = document.getElementsByTagN ame('head' ).item(0);
var js = document.createElement('sc ript');
js.setAttribute('language' , 'javascript');
js.setAttribute('type', 'text/javascript');
js.setAttribute('src', script_filename);
html_doc.appendChild(js);
return false;
}
after i call the include_dom function to access a .js file, i immediately start trying to use the .js file's functions. the problem i am having is that the browser is continuing to process the code before the .js file has been included and is running into problems trying to call a function that has not been loaded in the .js file yet.
I need a way to tell the browser to stop executing code until the include_dom function returns and the .js file has been added.
An example of my code is as follows:
include_dom('some_script.j s');
some_scripts_function();
what i am trying to do is call the following function to include a .js file so that its functions will be available to my program.
function include_dom(script_filenam
var html_doc = document.getElementsByTagN
var js = document.createElement('sc
js.setAttribute('language'
js.setAttribute('type', 'text/javascript');
js.setAttribute('src', script_filename);
html_doc.appendChild(js);
return false;
}
after i call the include_dom function to access a .js file, i immediately start trying to use the .js file's functions. the problem i am having is that the browser is continuing to process the code before the .js file has been included and is running into problems trying to call a function that has not been loaded in the .js file yet.
I need a way to tell the browser to stop executing code until the include_dom function returns and the .js file has been added.
An example of my code is as follows:
include_dom('some_script.j
some_scripts_function();
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
include_dom('some_script.j
window.setTimeout('some_sc