> 2009/3/29 Adam T <[email protected]> > > > String token = History.getToken(); > > if (token.length() != 0) { > > onHistoryChanged(token); > > } else { > > History.newItem(HIS_INTRO, true); > > }
On 29 mar, 14:02, Ian Bambury <[email protected]> wrote: > Hi Adam, > Your site does what mine does, i.e you end up with two history entries, one > for / and one for /#intro. > > I'm trying to avoid that so that if the user clicks the back button, they go > back to where they came from, not back to the page without the bookmark > (which in my case will redisplay the page with the bookmark), How about: String token = History.getToken(); if (token.length() != 0) { onHistoryChanged(token); } else { onHistoryChanged(HIS_INTRO, true); } which can also be written as: String token = History.getToken(); if (token.length() == 0) { token = HIS_INTRO; } onHistoryChanged(token); i.e. work as if the token were HIS_INTRO, even if it doesn't show in the URL; and use HIS_INTRO with History.newItem() to navigate to your "home page" because newItem() doesn't work reliably with an empty token. For my part, I've used a class to wrap all calls to History (including addHistoryListener) to ease things like "fire current history state only if it is equal to X" or "navigate to X, or fire current history state if it is already equal to X" that I use in async requests' callbacks (fire history change only if the user hasn't navigated away, i.e. has waited the async response / ensure we display X and/or "refresh" display of X by firing history change). My class' getToken() could (it doesn't now) return HIS_INTRO if History.getToken() returns the empty string. As for your OP, that's a know bug of WebKit <https://bugs.webkit.org/ show_bug.cgi?id=19202> . I can't tell for Opera as their bug database isn't public (but googling a bit showed that others have faced the same problem) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
