i am trying to go from page to page without reloading, i read on other questions that i can use
JavaScript
x
window.history.pushState()
to not reload the page, but it is still reloading the page.
i also tried using this function but kept giving me a syntax error
JavaScript
function changeurl(url, title) {
var new_url = '/' + url;
window.history.pushState('data', 'Title', new_url);
document.title = title;
}
the syntax error occurs and it reads: “unexpected token ,”
here is an example of my HTML:
JavaScript
<a class="ac" href="" onclick="window.history.pushState('data', 'Title', 'index?a=recieved');"></a></td>
<li>
<a class="" href="index?b=favorites" onclick=""></a></td>
</li>
<li>
<a class="" href="index?a=sent" onclick=""></a></td>
</li>
what can i do to get my pages not to reload?
Advertisement
Answer
Try this href=”javascript:void(0)” in tag a
JavaScript
<a class="ac" href="javascript:void(0)"
onclick="window.history.pushState('data', 'Title', 'index?a=recieved');">
Link
</a>