Making another script function call from javascript
I have developed a Javascript function My.js containing the following code
My.js
function display(){
//Call to another Javascript function defined as ShowUser() in selectUser.js
showUser(str);
}
SelectUser.js has
function showUser(Str){
//Do the display
}
Now, my question is, I want to call showUser () from within My.Js. Anyone how to call? Should I include anything?
source to share
You need to have separate script tags with the src attribute set for both javascript files in your HTML document, assuming this is for an HTML page (not an AIR application, or server-side JavaScript or Rhino). Regardless of the functions that you declare in the global scope in any JavaScript file added via a script element, or inline code must be available to JavaScript in any file.
The only caveat with this is that if you use the window.foo syntax to assign any global (window) scope in a file, then, surprisingly, in IE other files will think that window.foo is not assigned until JavaScript will not start execution.
source to share