最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - location.href = location.href wont redirect - Stack Overflow

programmeradmin2浏览0评论

In my javascript code, in some point, i need to refresh the window (user has uploaded new image but in page still can see it)

i am wondering why is

location.href = location.href

not refreshing the window?

In my javascript code, in some point, i need to refresh the window (user has uploaded new image but in page still can see it)

i am wondering why is

location.href = location.href

not refreshing the window?

Share Improve this question edited Jan 21, 2016 at 3:15 shmosel 50.7k7 gold badges78 silver badges145 bronze badges asked Feb 23, 2012 at 14:24 Toni Michel CaubetToni Michel Caubet 20.2k58 gold badges217 silver badges387 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 11

To refresh the window try:

window.location.reload();

If you are wanting your to redirect your page, use:

window.location = location.href;

Or, if it is a simple case of refreshing the page:

window.location.reload();

if you really really need to refresh the page you should do

 location.reload(true)
发布评论

评论列表(0)

  1. 暂无评论