mardi 28 juillet 2015

Removing Url and Include Id using Regex and Jquery

I am new to Regex and my question is how can i include the ID from the url and remove it using Regex? because as of now , It only removes the actionMe=reload&Id= but the Id still return so after removing it and replacing with new Url, the old id is still included plus the new ID,

Example, Before removing and replacing the Url:


And After Removing and replacing the url , it goes like this:


This is my Code Snippet:

var sss = $("#Id").val();
if (window.location.href.indexOf("&actionMe=reload&Id=") > -1) {
                    var regex = /(\&|&)actionMe=reload&Id=/;
                    var location = window.location.href;
                    if (regex.test(location)) {
                        window.location = location.replace(regex, "&actionMe=reload&Id=" + sss)


Thanks for Answering guys:)

Aucun commentaire:

Enregistrer un commentaire