Update location.hash without adding to history?

M

Mikey C

Hi Everyone,

I understand in many cases, adding to history when updating
window.location.hash is a GOOD thing. In my case, I want to update
bookmarkability from javascript (post-load), but can't get it to do so
without adding a record to history. (Firefox 3.0.3)

I know it's possible to do, because Google is doing it. See this
URL:
http://books.google.com/books?hl=en...m5xa&sig=Fas4pMfPxMIsahd4dysCVHe7_NU#PPA21,M1

Note, scrolling up and down changes the hash without adding history
entries.

Any idea how this is done? I have been looking for a solution for
months (on and off, but haven't found anything.)

Thanks,
-MIke C
 
D

David Mark

Hi Everyone,

I understand in many cases, adding to history when updating
window.location.hash is a GOOD thing.  In my case, I want to update
bookmarkability from javascript (post-load), but can't get it to do so
without adding a record to history.  (Firefox 3.0.3)

That would be a silly thing to do.
I know it's possible to do, because Google is doing it.  See this

There is confirmation.
URL:http://books.google.com/books?hl=en&lr=&id=mjvGTXgFl6cC&oi=fnd&pg=PP1...

Note, scrolling up and down changes the hash without adding history
entries.

That is not what the hash is for and there is little chance that
Google is doing anything right in their script.
Any idea how this is done?  I have been looking for a solution for
months (on and off, but haven't found anything.)

You wasted those months. Now re-think your design.
 
T

Thomas 'PointedEars' Lahn

Mikey said:
I understand in many cases, adding to history when updating
window.location.hash is a GOOD thing. In my case, I want to update
bookmarkability from javascript (post-load), but can't get it to do so
without adding a record to history. (Firefox 3.0.3)

I know it's possible to do, because Google is doing it. See this
URL:
http://books.google.com/books?hl=en...m5xa&sig=Fas4pMfPxMIsahd4dysCVHe7_NU#PPA21,M1

Note, scrolling up and down changes the hash without adding history
entries.

Any idea how this is done? I have been looking for a solution for
months (on and off, but haven't found anything.)

Well, the *location* is being *replace*d ...


HTH

PointedEars
 
M

Mikey C

Thanks so much! Seems pretty darn simple now, but this is huge for
me.

I had been setting window.location.hash = "value".
window.location.replace("value") works!

Thanks again!,
-Mike C
 
M

Mikey C

Still a silly idea, regardless of the perceived simplicity.

I didn't ask for a rating on the idea. I assure you, I explored
plenty of alternatives. This approach saves LOTS of extra server-side
processing that's just not needed.
 
T

Thomas 'PointedEars' Lahn

Mikey said:
I didn't ask for a rating on the idea.

The Good Thing about Usenet is that you get second opinions for free here :)
I assure you, I explored plenty of alternatives. This approach saves
LOTS of extra server-side processing that's just not needed.

I can see nothing inherently wrong with your approach. Unfortunately,
David did not present his arguments why he thinks it is a bad idea.


PointedEars
 
D

David Mark

The Good Thing about Usenet is that you get second opinions for free here:)


I can see nothing inherently wrong with your approach.  Unfortunately,
David did not present his arguments why he thinks it is a bad idea.

Anything that screws around with the location during scrolling is
obviously ill-advised. Yes, I know that "Mikey C" didn't say he was
doing that exactly, but implied it was something like that.
 
D

David Mark

I didn't ask for a rating on the idea.  I assure you, I explored
plenty of alternatives.  This approach saves LOTS of extra server-side
processing that's just not needed.

Never mind what you asked for, don't SHOUT at me and get a real name.
 
E

Evertjan.

Lars Rune Nøstdal wrote on 24 nov 2008 in comp.lang.javascript:
I'm using `window.location.replace' in some of my applications and it is
IMHO useful in some rare (at least for me up until now) but important
cases. Problem is, Opera and Webkit(Safari & Chrome) does not seem to
support this (very old and basic!) feature or function correctly:

http://common-lisp.net/~lnostdal/webkit-and-opera-history-fail.html


..quite annoying. Anyone know how to do this?

How to quit annoying?
 
T

Thomas 'PointedEars' Lahn

David said:
Thomas said:
I can see nothing inherently wrong with your approach. Unfortunately,
David did not present his arguments why he thinks it is a bad idea.

Anything that screws around with the location during scrolling is
obviously ill-advised. [...]

It is not obvious to me at least. Suppose you have a Web application where
you would use the location hash to (re)store a certain state[1], and
scrolling down would change that state; why would it be a problem to restore
what was being scrolled to previously, if real navigation took place and the
user came back from the other document?

[1] simple example: <http://validator.w3.org/#validate-by-input>


PointedEars
 
D

David Mark

Anything that screws around with the location during scrolling is
obviously ill-advised. [...]

It is not obvious to me at least.  Suppose you have a Web application where

Calling location.replace while scrolling is not obviously ill-
advised? You don't see that?
you would use the location hash to (re)store a certain state[1], and

I am familiar with the technique.
scrolling down would change that state; why would it be a problem to restore
what was being scrolled to previously, if real navigation took place and the
user came back from the other document?

It wouldn't be.

Site is swamped at the moment it seems, but I am familiar with the
document. Something tells me that the hash references an anchor (as
it should.) IIRC, there is a scripted enhancement that hides parts of
the document initially and it makes sense for that script to reference
the hash to initialize properly. That is hardly the same thing.
 
T

Thomas 'PointedEars' Lahn

David said:
Thomas said:
David said:
Thomas 'PointedEars' Lahn wrote:
Mikey C wrote:
I assure you, I explored plenty of alternatives. This approach saves
LOTS of extra server-side processing that's just not needed.
I can see nothing inherently wrong with your approach. Unfortunately,
David did not present his arguments why he thinks it is a bad idea.
Anything that screws around with the location during scrolling is
obviously ill-advised. [...]
It is not obvious to me at least. Suppose you have a Web application where

Calling location.replace while scrolling is not obviously ill-
advised? You don't see that?

Yes, I don't. Therefore, if you were to convince me that you are right (and
not simply posing here), it would be up to you to provide good arguments to
that end. Unfortunately, so far, nothing.
you would use the location hash to (re)store a certain state[1], and

I am familiar with the technique.
scrolling down would change that state; why would it be a problem to restore
what was being scrolled to previously, if real navigation took place and the
user came back from the other document?

It wouldn't be.

You have to do better than that.


PointedEars
 
D

David Mark

David said:
Thomas said:
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
Mikey C wrote:
I assure you, I explored plenty of alternatives.  This approach saves
LOTS of extra server-side processing that's just not needed.
I can see nothing inherently wrong with your approach.  Unfortunately,
David did not present his arguments why he thinks it is a bad idea.
Anything that screws around with the location during scrolling is
obviously ill-advised. [...]
It is not obvious to me at least.  Suppose you have a Web application where
Calling location.replace while scrolling is not obviously ill-
advised?  You don't see that?

Yes, I don't.  Therefore, if you were to convince me that you are right(and
not simply posing here), it would be up to you to provide good arguments to
that end.  Unfortunately, so far, nothing.
you would use the location hash to (re)store a certain state[1], and
I am familiar with the technique.
It wouldn't be.

You have to do better than that.

No, I really don't. Do whatever you like.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top