No, this is not possible, and not in any case. According to the MDC, the "state object", that is, the first argument to pushState , "can be anything that can be serialized." Unfortunately, you cannot serialize a function. The WHATWG spec says basically the same thing, but in many other words, the essence of which is that functions are explicitly forbidden in the state object.
The solution is to save either a string that you can eval or a function name in a state object, for example:
$(window).bind("popstate", function(event) { var state = event.originalEvent.state; if ( !state ) { return; } window[ state.callback ]( state.argument ); // <-- look here } function beforeLoad() { var resourceId = "xyz", func ; if ( case1 ) { func = "switchPageToMode1"; // <-- string, not function } else { // case 2 func = "swithPageToMode2"; } window[ func ]( resourceId ); // <-- same here window.history.pushState( { callback : func, argument : resourceId }, "newTitle", "newURL" ); }
Of course, assuming switchPageToMode1 and -2 are in a global context (i.e. window ), which is not best practice. If not, they should be accessible in some way from the global context, for example. [window.]MyAppGlobal.switchPageToMode1 , in which case you call MyAppGlobal[ func ]( argument ) .
source share