I have a jQuery tabs set up on a page on my website. I want to reference one of the tabs using a URL which I can do using:
http://url.com/tabs#my-tab
However, I also want to pass a few php variables to this page THROUGH the url as well. I have tried with minimal success by doing this:
http://url.com/tabs?var1=foo&var2=bar#my-tab
however this only seems to pass the first variable, the second one is ignored (it does go to the tab). I cannot find a way to send several variables and go to the tab. Can someone please help Thanks
Without seeing your code, I would guess that whatever method you're using to parse those GET variables isn't working. Try this method instead. First, do the following:
// Store the query string variables into an object.
window.getVars = {};
(function () {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
while (match = search.exec(query))
window.getVars[decode(match[1])] = decode(match[2]);
})();
Then, you should be able to access any of your GET variables as window.getVars.var1
, window.getVars.var2
, etc.