I want to add a parameter to url. Here problem is when I click a tag history.pushState is working but after removing parameter. Firstly, history.pushState is changing to /general-info-21,2231-44,333 after url changing to /general-info. How can I solve?
HTML
<ul>
<li><a href="/general-info" data-desc="general-info" onclick="dataInfo($event)">General Info</a></li>
</ul>
JS
function dataInfo($event){
var desc = $($event.target).attr("data-desc");
lat="21,2231";
lng="44,333";
history.pushState(null, null, desc + "-" + lat + "-" + lng);
}
atag does what it should. In your function you can try to disable the default behaviour using$event.preventDefault();at the top of the handler.