Force top of page on refresh

Hi, I’m using the code to reload at top of page when refresh is pressed.:

    </script>type or paste code here

but it’s not working, I think it’s because the url contains “#pic10” pointing to the location within the page before clicking refresh, how do I force top of page when I click refresh.
Thanks for any help

I’ve used this in the past:

window.onbeforeunload = function () {
  window.scrollTo(0, 0);

Not something I have had to to before (or remember doing). You can try the following in the head of your page.

    if (window.location.hash === '#pic10') {
        window.location.hash = "";

or to ignore all hashtag anchor links.

<script> window.location.hash = ""; </script>

Thanks Ryan, worked perfectly.