I use jQuery to change the hash of the URL when I click on the navigation button. But when I scroll with the mouse wheel, the URL will not change. How can i do this? How to do it using
window.history.pushState("object or string", "Title", "/new-url");
I canβt understand it. Please help my javascript code
$j(document).ready(function () { $j("#start1").click(function (e) { e.preventDefault(); var section = this.href, sectionClean = section.substring(section.indexOf("#")); $j("html, body").animate({ scrollTop: $j(sectionClean).offset().top }, 1000, function () { window.location.hash = sectionClean; }); }); }); $j(document).ready(function () { $j("#start2").click(function (e) { e.preventDefault(); var section = this.href, sectionClean = section.substring(section.indexOf("#")); $j("html, body").animate({ scrollTop: $j(sectionClean).offset().top }, 1000, function () { window.location.hash = sectionClean; }); }); });
and html code
<a href="#home" id="start1"style="text-decoration:none;position:absolute;right:450px;top:37px;font-weight:bold;color:white;font-size:15px;z-index:200;transition:0.5s" onmouseover="big(this)" onmouseout="small(this)"><span >HOME</span></a> <span><a href="#products" id="start2" style="text-decoration:none;position:absolute;right:250px;top:37px;font-weight:bold;color:white;font-size:15px;transition:0.5s" onmouseover="big(this)" onmouseout="small(this)">PRODUCTS & SERVICES</a></span>
javascript jquery html5 try-catch
Kushagra singh rajput
source share