[ 3 posts ]

Matt C.

  • Username: MattAreSmart
  • Joined: Tue Apr 20, 2010 3:15 pm
  • Posts: 2
  • Twitter: MattAreSmart
  • Offline
  • Profile

Browser History & Get Vars

Post Posted: Tue Apr 20, 2010 4:06 pm
+0-
Recently...as in 2 days ago...decided to switch to YUI from jQuery. Everything is working great, but I have a small question.

Is there a quick and not so dirty way to force the Browser History widget to remove anything from location.href - that isn't either the base location or the hash - from the display but not from the history?

ie...

Search form executes....

Code:
http://www.mydomain.com/pages/?what=something&where=somethingelse

is displayed. Then the user click somewhere that is hooked into the browser history widget and they're sent to...
Code:
http://www.mydomain.com/pages/?what=something&where=somethingelse#nav=home

I want this displayed as...
Code:
http://www.mydomain.com/pages/#nav=home

without a cookie or a double page load or switching to a POST form.

YAHOO.util.History.getQueryStringParameter only lets me intercept the hash and I'm not seeing anything that exposes the location.href without getting inside the widget itself. Can anyone point me in the right direction?

Thanks,

matt

Ryan Grove

YUI Developer

  • Username: rgrove
  • Joined: Tue Dec 09, 2008 9:55 pm
  • Posts: 275
  • Location: Portland, OR
  • Twitter: yaypie
  • GitHub: rgrove
  • Gists: rgrove
  • IRC: rgrove
  • YUI Developer
  • Offline
  • Profile

Re: Browser History & Get Vars

Post Posted: Tue Apr 20, 2010 6:32 pm
+0-
Unfortunately, changing any part of window.location other than window.location.hash will cause the browser to make a new request for the changed URL, so it's not currently possible to accomplish what you want.

The new HTML5 History API adds the ability to change the displayed URL without causing a new request. I plan to add support for the HTML5 History API in YUI 3.2.0, but browser support is currently slim; as far as I know, it's only supported in Firefox 3.7 and recent Chrome dev builds.

Matt C.

  • Username: MattAreSmart
  • Joined: Tue Apr 20, 2010 3:15 pm
  • Posts: 2
  • Twitter: MattAreSmart
  • Offline
  • Profile

Re: Browser History & Get Vars

Post Posted: Wed Apr 21, 2010 6:39 am
+0-
Thanks for the quick answer. After reading it, I reworked the form and its related code, changing it to use POST. That took care of the issue. Wasn't intending to come across as lazy, just trying to get my arms completely around YUI since I've been on jQuery so long. Thanks again.

matt
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum