Javascript: How to truly reload a site with an anchor tag?

aefxx picture aefxx · Feb 23, 2010 · Viewed 47.1k times · Source

Take this code snippet for example:

window.location.href = 'mysite.htm#images';

Already being on the site mysite.htm and triggering the reload thru location.href won't reload the page but jump to the anchor named within the URL.

I need a mechanism to truly reload the page. Any ideas?

PS: I tried location's other methods but none of them does the trick :(

EDIT
Don't hang on the filetype htm. I'd need it for dynamic sites as well.

Answer

alemjerus picture alemjerus · Feb 23, 2010

After you set the specified URL into location, issue window.location.reload(true). This will force browser to reload the page.