Firefox 中与 JavaScript 事件相关的 F5 和 Ctrl-F5 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7768459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 03:32:41  来源:igfitidea点击:

What's the difference between F5 and Ctrl-F5 in Firefox related to JavaScript events?

javascriptajaxfirefoxpage-refresh

提问by Abel

When you try this public page: http://slim.nl/shop/default.aspx(update: meanwhile this site has changed such that this question's behavior cannot be tested anymore there), you'll notice a menubar. If you hit F5, the menu in that bar disappears. Same when you come to that page via the Back-button in your browser. It only happens on Firefox (seen on versions 3-7). Using Ctrl-F5, the menubar reappears.

当您尝试此公共页面时:http: //slim.nl/shop/default.aspx(更新:同时此站点已更改,因此无法再在那里测试此问题的行为),您会注意到一个菜单栏。如果您点击F5,该栏中的菜单就会消失。当您通过浏览器中的后退按钮进入该页面时也是如此。它只发生在 Firefox 上(见版本 3-7)。使用Ctrl- F5,菜单栏会重新出现。

To the best of my knowledge, all JavaScript events that fire when loading a page, including any AJAX cycles, should also fire when refreshing a page with F5or coming there via the Back-button. What's happening here?

据我所知,加载页面时触发的所有 JavaScript 事件,包括任何 AJAX 循环,也应该F5在使用后退按钮刷新页面或通过后退按钮进入页面时触发。这里发生了什么事?

I'd like to know from a programmer's standpoint what the difference is between F5and Ctrl-F5, preferably more general than just this case. Unless it's a bug in Firefox, of course.

我想从程序员的角度知道F5Ctrl-之间的区别是什么F5,最好比这种情况更通用。当然,除非它是 Firefox 中的错误。

enter image description here

enter image description here

采纳答案by Vasiliy Shiryaev

Firefox caches not only loaded files but changes made to page( user input and even changes to attributes made by JavaScript). Check this. So if your menu depends on some attributes you can just hard-refreshby clicking CTRL+F5.

Firefox 不仅会缓存加载的文件,还会缓存对页面所做的更改(用户输入,甚至是 JavaScript 对属性所做的更改)。检查这个。因此,如果您的菜单取决于某些属性,您只需hard-refresh单击CTRL+ 即可F5

回答by Alistair Laing

Ctrl+F5clears the cached files in browsers where as F5just refreshes the page but it uses cached files. Eg say you load a page make changes to a css file and upload it press refresh or F5. Page just refreshes and doesn't fetch the new revised css file hit ctrl+F5it goes it clears the cache for the page and fetches the file again from the server. This would then load the new css file which would display the changes.

Ctrl+F5清除浏览器中的缓存文件,其中F5仅刷新页面但使用缓存文件。例如,假设您加载一个页面,对 css 文件进行更改并按刷新或F5. 页面只是刷新并且不会获取新修改的 css 文件命中ctrl+F5它会清除页面的缓存并再次从服务器获取文件。然后这将加载将显示更改的新 css 文件。

回答by hugomg

ctrl+F5 will just force the cache to be ignored. Perhaps you have a subtle asynchronous-programming bug that is only surfaces when you have a faster page load (due to using the cache).

ctrl+F5 只会强制忽略缓存。也许你有一个微妙的异步编程错误,只有当你有更快的页面加载(由于使用缓存)时​​才会出现。

回答by Andy

That issue was fixed by rolling-back \js\dnn.controls.dnnmenu.js file to previous version. Not sure what was wrong there(didn't have time to debug), but anyway now it works:)

该问题已通过将 \js\dnn.controls.dnnmenu.js 文件回滚到以前的版本来解决。不确定那里出了什么问题(没有时间调试),但无论如何现在它可以工作了:)