Link to anchor in the same page and refresh page before going to the anchor


I have a page with a series of links to anchors in the same page, and I need a script that refresh the page on clicking any of them without altering the hash in the url.

If we are in this URL: www . page . com/page#first

I have tested these three so far:

<a href="#second" onClick="openWindowReload(this)">Second</a>

This one goes to the anchor but does not reload the page.

<a href ='!#second' onclick='location.reload(true); return false;'>Second</a>

This one reloads the page but does not go to the anchor.

<a href="!#second" onClick="window.location.reload(true);">Second</a>

This one first seems to go to the anchor, changes the hash, but then the hash change again, the page refresh and goes to the First anchor again. So goes to nowhere.

Some idea??

!#anchor is not a valid URL anchor.

what could work is that you first go to the anchor and then reload the page.

untested, but might work:

window.location.href += '#anchor';

or possibly

window.location.hash = 'anchor';

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.