wouldn't be easier to use`if (window.location.hash = '#edit)`  ?