Javascript:如何使用锚标记真正重新加载网站? [英] Javascript: How to truly reload a site with an anchor tag?
问题描述
以此代码段为例:
window.location.href ='mysite.htm#images';
已经在网站上 mysite.htm
并通过 location.href
触发重新加载将不会重新加载页面,而是跳转到URL中指定的锚点。
<我需要一种机制来真正重新加载页面。任何想法?
PS:我尝试过location的其他方法,但没有一个方法可以解决问题:(
编辑
不要挂在文件类型 htm
。我也需要动态网站。
将指定的URL设置为位置后,发出 window.location.reload(true)
。这将强制浏览器重新加载页面。
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.
After you set the specified URL into location, issue window.location.reload(true)
. This will force browser to reload the page.
这篇关于Javascript:如何使用锚标记真正重新加载网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!