开发者

Can I tell Javascript to call a method from another JS file?

开发者 https://www.devze.com 2023-03-17 06:31 出处:网络
In AppMenu.js, AppMenu = function() { var scope = this; } Also noted: Star.Bus.addEvent(\"AppMenu_StatSheet\");

In AppMenu.js,

AppMenu = function()
{
   var scope = this;
}

Also noted:

Star.Bus.addEvent("AppMenu_StatSheet");
Star.Bus.on("AppMenu_StatSheet", scope.AppMenu_StatSheet, scope);
scope.registerApp("Exit Game", "AppMenu/images/exit_button.png", "AppMenu_exit", "");

Further down is a method

scope.AppMenu_StatSheet = function()
{
    showStats();
}

I moved the location of the showStats() method to another js file, and I want the method to send its call there instead of where it originally was going. In Javascript, can I tell the program where to开发者_JAVA百科 look to call showStats()?

EDIT Curiously, there is no AppMenu.html. I now believe that all of the html is dealt with by a main HTML file in the above folder.


If you include both Javascript files in your PHP/HTML page, the compiler automatically uses your showStats() function, even when it is called from file1.js and the actual function is located in file2.js.


As long as you include both files in your HTML page you'll be fine. Maybe load the file with showStats() before the other one.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号