views:

396

answers:

1

I need to get the a parameter passed via a querystring. I need to get the value of the parameter and then use it in some javascript.

In my specific example, I am using the "tabview" object and would like to set the "selected" tab by getting it from the querystring. The querystring would be something like this

http://www.myserver.com/pagex.html?tab=3

So, I want to get the "tab" parameter and extract the value to preset the tab on form i am displaying..

Thanks..

+4  A: 

It's well hidden in the History module.

If you have a page at a url like:

http://my.site.com/foo.html?QUERY=bar&OTHER=stuff

Then you can get the value for QUERY using:

var string = YAHOO.util.History.getQueryStringParameter('QUERY'); //returns "bar"
Gavin Brock
Thanks gavin.. This is exactly what I was trawling for.. Just couldn't find it...
giulio
Well hidden indeed! I was searching specifically for an YUI method to do this today, but for instance if you search for "YUI get url parameter" in Google you will not find any mention to the History module in the search results.
rodbv
I know..YUI team are too busy making all their widgets to realise, that you gotta start with some basics.. More info herehttp://developer.yahoo.com/yui/docs/YAHOO.util.History.html
giulio