使用JavaScript重写或禁用元刷新标记 [英] Using Javascript to override or disable meta refresh tag
问题描述
我有一个网站,在这里我想使用Ajax来更新页面上的一些东西,而无需重新加载它。然而,有一个很好的机会,我的很多用户都会使用不支持JavaScript的移动浏览器,所以我想设计的页面与元刷新标记,以某种方式只对没有JavaScript的用户使用。有没有办法做到这一点?
I have a website, where I am trying to use Ajax to update some stuff on the page without reloading it. However, there is a good chance that many of my users will be using mobile browsers that don't support Javascript so I am trying to design the page with meta refresh tags, that somehow work only for users without Javascript. Is there any way to do this?
我试图把标签,无脚本元素中,但我的基本的手机浏览器也不会承认这一点。我想到的可能设置cookie要记住,如果用户的浏览器支持JavaScript,或者具有工作没有JavaScript,并尝试使用JavaScript来将用户重定向到一个更复杂的版本页面的一个版本,但我想知道是否有是一种更优雅的方式来做到这一点。有没有人有什么想法?
I tried putting the tag within a noscript element, but my primitive cell phone browser wouldn't acknowledge it. I am thinking of maybe setting a cookie to remember if the user's browser supports Javascript, or having one version of the page that works without Javascript, and tries to use Javascript to redirect the user to a more sophisticated version, but I am wondering if there is a more elegant way to do it. Does anyone have any ideas?
推荐答案
您不能覆盖元刷新标记的JavaScript。
You cannot override meta refresh tag with JavaScript.
不过,你可以做到这一点。
However you can do this
假设你的网页是在 - >
Suppose your page is at ->
http://example.net/mike.html 将下面的code有 - >
http://example.net/mike.html Put the following code there->
<script type="text/javascript">
window.location = 'http://example.net/mike/for_Those_With_JavaScript_Enabled.html';
</script>
这篇关于使用JavaScript重写或禁用元刷新标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!