admin管理员组

文章数量:1346682

I have Designed the Javascript function My.js it contains 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 My.Js itself. Any one suggest how to make the call? Should I include anything?

I have Designed the Javascript function My.js it contains 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 My.Js itself. Any one suggest how to make the call? Should I include anything?

Share Improve this question edited Sep 23, 2013 at 22:47 Gabriele Petronella 108k21 gold badges221 silver badges236 bronze badges asked Jan 1, 2009 at 3:47 venkatachalamvenkatachalam 102k31 gold badges74 silver badges77 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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 (and not an AIR app, or serverside JavaScript, or Rhino). Whatever functions you declare in the global scope in any JavaScript file you add via a script element, or inline code should be available to JavaScript in any file.

The only caveat to this is that if you use window.foo syntax to assign something to the global (window) scope in a file then, surprisingly in IE, other files will think window.foo is unassigned until JavaScript begins executing.

More Info on that last issue

本文标签: Making a another script function call from javascriptStack Overflow