yhyu1220 / reallysimplehistory

Automatically exported from code.google.com/p/reallysimplehistory
Other
0 stars 0 forks source link

Blank history keys cause reload #87

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
(Enhancement suggestion, not defect.)

What steps will reproduce the problem?
1. Call add to set a location "test", then call it to set ""

What is the expected output? What do you see instead?
I expect the hash to disappear.
Instead, it causes a page reload.

What version of the product are you using? On what operating system?
0.6 final on Windows XP

Please provide any additional information below.
This is not a defect in RSH, it appears to be browser behavior as I can 
easily replicate it without RSH just setting location.hash to ''.
RSH can work around it, though:  If you set location.hash to '#' instead in 
that situation, although you see the hash mark in the location bar, other 
than that your location is effectvely "" -- e.g., if you ask RSH what the 
current location is, or if you navigate away and then back, etc.  So a very 
satisfying workaround.

So my modified RSH now has this new private function:

    /*Private: Set the location.hash*/
    setHash: function(hash) {
        window.location.hash = hash ? hash : '#';
    },

...and uses that rather than setting window.location.hash directly.

FWIW,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

Original issue reported on code.google.com by tj%crowd...@gtempaccount.com on 1 Aug 2009 at 11:01