meta 刷新
A few days back I was perusing the ESPN.com source code when I found the following snippet of code:
几天前,当我发现以下代码片段时,我正在细读ESPN.com源代码:
<script>
ESPN_refresh=window.setTimeout(function(){window.location.href=window.location.href},900000);
</script>
<noscript>
<meta http-equiv="refresh" content="900" />
</noscript>
I understand what the code was supposed to do but was confused as to why they'd use JavaScript as a primary method and META as a fallback method. Why not just use the META method? I did some research and found the answer at Wikipedia:
我了解代码应该执行的操作,但是对于为什么将JavaScript作为主要方法而将META作为后备方法的原因感到困惑。 为什么不只使用META方法呢? 我做了一些研究,并在Wikipedia上找到了答案:
Use of meta refresh is discouraged by the W3C, since unexpected refresh can disorient users. Meta refresh also impairs the web browser's "back" button in some browsers (including Internet Explorer 6 and before), although most modern browsers compensate for this (Mozilla Firefox, Opera, Internet Explorer 7).
W3C不鼓励使用元刷新,因为意外刷新可能会使用户迷惑。 元数据刷新还会损害某些浏览器(包括Internet Explorer 6和更低版本)中Web浏览器的“后退”按钮,尽管大多数现代浏览器都对此进行了补偿(Mozilla Firefox,Opera,Internet Explorer 7)。
So there you have it. Use JavaScript as your primary means for automatic page refreshes and a META tag as your fallback.
所以你有它。 使用JavaScript作为自动刷新页面的主要方法,并使用META标签作为后备。
meta 刷新