views:

26

answers:

1
var game = (function() {

    function start() {
        //somefunction
    }

    function save_count(someparamt) {
        //somefunction
    }

})();

How could I trigger savecount() from the browser url? javascript:savecount(); won't work and neither game.savecount() and neither window.game.savecount();

+2  A: 

You probably meant to do this:

var game = {

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

};

Yes, this will push the game object into global scope.

Jacob Relkin