Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2010, 03:31 PM   PM User | #1
tribalmaniac
Regular Coder

 
Join Date: Sep 2006
Posts: 122
Thanks: 4
Thanked 2 Times in 2 Posts
tribalmaniac is an unknown quantity at this point
window.location.hash

Hi,

If you use inline JavaScript to forward a page to a new hash e.g:
window.location.hash = 'action=test'; The onhashchange even doesn't fire.

This is a good thing, because it means you can set up an initial hash representing the AJAX state. However the back button would take you from
http://example.com/#action=test to http://example.com/

Which creates a usability problem as the back button then has to be pressed twice to actually go back.

SOMEHOW Google manage to avoid this. To see, open docs.google.com in a new window or tab and you will be taken to http://docs.google.com/#all
And yet the back button is disabled - as if the transition to #all never even happened.

Does anybody know how they do this? As it would solve the double back button problem I mentioned above.

(This doesn't appear to be a serverside redirect as the hash appears once the page has loaded).

Last edited by tribalmaniac; 07-05-2010 at 04:20 PM..
tribalmaniac is offline   Reply With Quote
Old 07-05-2010, 03:38 PM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
maybe htaccess solves this.
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 07-05-2010, 03:47 PM   PM User | #3
tribalmaniac
Regular Coder

 
Join Date: Sep 2006
Posts: 122
Thanks: 4
Thanked 2 Times in 2 Posts
tribalmaniac is an unknown quantity at this point
Mmmm, I'm not so sure. Do you see the hash appearing once the page has loaded - and yet the back button is still disabled.

Last edited by tribalmaniac; 07-05-2010 at 03:50 PM..
tribalmaniac is offline   Reply With Quote
Old 07-05-2010, 03:57 PM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
as long as the document is open in a new tab, the back button is disabled, no wonder...
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 07-05-2010, 04:01 PM   PM User | #5
tribalmaniac
Regular Coder

 
Join Date: Sep 2006
Posts: 122
Thanks: 4
Thanked 2 Times in 2 Posts
tribalmaniac is an unknown quantity at this point
I don't think you understand, Google, and the code I mention both forward the browser to a new hash.
(I only mention opening a new window so you can see the effect.)

In my case this enabled the back button as in my first example.
However, Google's case - the back button does not become enabled.

Last edited by tribalmaniac; 07-05-2010 at 04:10 PM..
tribalmaniac is offline   Reply With Quote
Old 07-05-2010, 04:54 PM   PM User | #6
tribalmaniac
Regular Coder

 
Join Date: Sep 2006
Posts: 122
Thanks: 4
Thanked 2 Times in 2 Posts
tribalmaniac is an unknown quantity at this point
I found a post regarding the same problem:

http://bytes.com/topic/javascript/an...adding-history

The solution is to use window.location.replace initially and window.location.hash thereafter.

Last edited by tribalmaniac; 07-06-2010 at 11:04 AM..
tribalmaniac is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:45 AM.


Advertisement
Log in to turn off these ads.