views:

2971

answers:

1

D ear All, 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 make call showUser() from My.Js itself, Any one suggest me How to make call, should i include anything?

+3  A: 

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

apphacker
I want to Know call function from One javascript function to another function defined in another script , any idea to declare global function ,Its not the HTML part !,Its Javascript issue
venkatachalam
Bjorn's answer looks right to me. Are you not using this in a web page?
Jeremy Bade
venkatachalam there's no special syntax for it required, just call the function.
apphacker