0
var game = (function() {

    function start() {
        //somefunction
    }

    function save_count(someparamt) {
        //somefunction
    }

})();

如何savecount()从浏览器 url 触发? javascript:savecount();不会工作,也不会game.savecount(),也不会window.game.savecount();

4

1 回答 1

2

您可能打算这样做:

var game = {

    start:function() {
        //somefunction
    },
    save_count:function(someparamt) {
        //somefunction
    }

};

是的,这会将对象推game入全局范围。

于 2010-10-11T00:05:35.477 回答