[Javascript] window location hash

Nick Fitzsimons nick at nickfitz.co.uk
Thu Mar 22 11:00:33 CDT 2007


On 22 Mar 2007, at 15:39:52, Glenn E. Lanier, II wrote:

>> 	Setting location.hash to the same value twice in a row causes Safari
>> to reload the page. Tested in Safari 1.1-1.2 and equivalent OmniWeb
>> versions.
>
> Untested, but would
>
> var hashValue = "bottomPage";
> if (hashValue != window.location.hash)
> {
> 	window.location.hash = hashValue;
> }
>
> work?
>

I wouldn't have thought so, although it depends on the circumstances.  
Consider the following scenario:

1. I do something which causes the "location.hash" property to be set  
to "botttomPage", resulting in the browser bringing that region of  
the page into view;
2. I scroll the page back up, such that the "bottomPage" element is  
no longer in view;
3. I do something else which is supposed to take me to "bottomPage"  
as in step 1.

At step 3, "location.hash" would still have the value "bottomPage",  
so I wouldn't be taken there.

:-(

Regards,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/






More information about the Javascript mailing list