javascript - Location.Hash does not update in Chrome -


i trying store state of page in hash. works in ie , ff in chrome not seem anything

$(document).ready(function() {     window.onbeforeunload = savepagestate; });  function savepagestate() {     var currenttab = _tabbing.getcurrenttab();      var mapstate = _mapadapter.getmapstate();     window.location.hash =         'reload=' + currenttab +         '&maptype=' + mapstate.maptype.getname() +         '&lat=' + mapstate.latitude +         '&long=' + mapstate.longitude +         '&zoom=' + mapstate.zoomlevel;      return; } 

is there quirk in chrome prevents me updating hash? there better way go saving pages state? button needs saved.

i'd recomend use jquery bbq plugin, manages hash you.

$.bbq.pushstate({     reload: currenttab,     maptype: mapstate.maptype.getname(),     lat: mapstate.latitude,     long: mapstate.longitude,     zoom: mapstate.zoomlevel }); 

bbq handles merging hash, not overwrite other parameters. example, #fun=yes becomes #fun=yes&reload=tab&...

next, can listen changes hash:

$(window).bind('hashchange', function(e) {     var params = e.getstate();     dostuff(params.lat, params.long); }); 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -