I have the following url
http://www.domain.com?page=options&tab=general
I want to be able to get to the tab parameter and change it e.g
I have two tabs General & Styles and when I click on styles, I want a hidden field(that has this url as a value) to change so that it reads the same url but with the tabs parameter changed to styles. So it would look like this
http://www.domain.com?page=options&tab=styles
However, this url may not have the parameter tab when the page is loaded so i need to be able to add a parameter to the url query string.
There will be many more tabs so I cannot just replace the text general with styles
Anyone know? Thanks
var s = "http://www.domain.com?page=options&tab=general"
var queryString = s.substring(s.lastIndexOf("?") + 1);
var newQueryString = $.map(queryString.split("&"), function(pair) {
var p = pair.split("=");
if (p[1] == "general") {
p[1] = "styles";
return p.join("=");
} else {
return pair;
}
}).join("&");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With