[Javascript] window location hash

Guillaume javascript at webdesignofficina.com
Fri Mar 23 06:39:06 CDT 2007


Thanks all for your responses.
I've tryed the different suggestions. All work but don't solve the 
initial bug.
I need the hash because I need bottom and top of page to be reached with 
a keypress.
Here's an example: http://www.hablablow.com/devX/hash/hash.html
You'll see the bug when opening the url in Safari and in a tab.
Two keypress are active *b* ( reach bottom of page ) and *u* ( reach top 
of page ).
Press any of these two and you'll see that Safari loops loading the page 
( notice the loading icon in the tab above ).
Here's what I end with:

 var hashValue = "bottomPage";
 if (hashValue == window.location.hash)
{
window.location.hash = new String((new Date().getMilliseconds()));
}
window.location.hash = hashValue;
}

Here's a reminder of the bug description that occurs only on Safari:

(...)
- What is going on here?
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.
- What can be done to workaround this bug?
Don't set location.href to the same value twice in a row. If needed, set 
it to an intermediate value in between.
(...)

Here's an example: http://www.hablablow.com/devX/hash/hash.html

Thanks.

Guillaume.


> On 3/22/07, Glenn E. Lanier, II <glenn_lanier at netzero.net> wrote:
>
>> Untested, but would
>>
>> var hashValue = "bottomPage";
>> if (hashValue != window.location.hash)
>> {
>>         window.location.hash = hashValue;
>> }
>
> It will avoid the bug but probably will not do what is intended by the
> hash change in the first place. A slight modification:
>
> if (hashValue == window.location.hash)
> {
>        window.location.hash = new String((new Date().getMilliseconds()));
> }
> window.location.hash = hashValue;
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20070323/c10c667a/attachment.htm>


More information about the Javascript mailing list