1
function loadThisUrl(yr){
    if ('URLSearchParams' in window) {
        var searchParams = new URLSearchParams(window.location.search);
        searchParams.set("get_of_year", yr);

        window.location.search = searchParams.toString();
        //window.location.hash="yeartabwrapper";
    }
}

This code generates the url like:

http://localhost/gipfipan/pedagogical-action/update?id=5&get_of_year=2017

and I want like below url:

http://localhost/gipfipan/pedagogical-action/update?id=5&get_of_year=2017/#yeartabwrapper
Nisarg Shah
  • 14,151
  • 6
  • 34
  • 55
Umashankar Saw
  • 1,131
  • 1
  • 9
  • 25

1 Answers1

1

If you do assign the hash before search it will work

function loadThisUrl(yr){
    if ('URLSearchParams' in window) {
        var searchParams = new URLSearchParams(window.location.search);
        searchParams.set("get_of_year", yr);
        window.location.hash="yeartabwrapper";
        window.location.search = searchParams.toString();
    }
}
Vineesh
  • 3,762
  • 20
  • 37