[Javascript] window location hash

Guillaume javascript at webdesignofficina.com
Fri Mar 23 10:24:59 CDT 2007


Flávio,

the way you built it, it's reloading the entire page to the url with 
#bottompage next to it.

Guillaume.
> As I dont have Safari here, lets try some shots in the dark =)
>
> What would happen if you set the location to "location.href" + 
> '#bottomPage', instead of using the location.hash?
>
>
>  location.href = location.href.split('#')[0] + "bottomPage"; //Spooky 
> Code :-O
>
>
> Guillaume escreveu:
>
>> 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;
>>>
>>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
>>  
>>
>




More information about the Javascript mailing list