简体   繁体   English

Window.Locaton.reload()在不同的浏览器(Firefox,Chrome)中的行为有所不同

[英]Window.Locaton.reload() behaves differently in different browsers (fire fox , Chrome)

I am quite new to JavaScript, I have written some code that just reloads the page 我对JavaScript很陌生,我写了一些代码来重新加载页面

window.location.reload()

When I run the application in Firefox it re-posts the form and when I run the application in Chrome it redirects to another page. 当我在Firefox中运行该应用程序时,它将重新发布该表单,而当我在Chrome中运行该应用程序时,它将重定向到另一个页面。

What are the mechanism of the browsers (Firefox, Chrome) when the page is reloaded using window.location.reload() ? 使用window.location.reload()重新加载页面时,浏览器(Firefox,Chrome)的机制是什么?

According to w3school. 据w3school。 The reload() method does the same as the reload button in your browser reload()方法的作用与浏览器中的reload按钮相同

syntax is 语法是

location.reload(forceGet)

forceGet is optional. forceGet是可选的。 default false which reloads the page from the cache. 默认为false,它从缓存中重新加载页面。 Set this paramter to true if you want to force the browser to get the page from the server 如果要强制浏览器从服务器获取页面,请将此参数设置为true

also you can use href for reload the page. 您也可以使用href重新加载页面。

window.location.href="";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM