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
  • 13,626
  • 5
  • 36
  • 53
Umashankar Saw
  • 1,051
  • 1
  • 9
  • 23

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,677
  • 20
  • 35