Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Javascript to override or disable meta refresh tag

Tags:

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?

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?

like image 954
Elias Zamaria Avatar asked Jul 15 '10 05:07

Elias Zamaria


People also ask

How do I stop meta refresh?

Click the Start button, type “internet options” and select Internet Options in the search results. In the Internet Properties window, click “Custom tab -> Custom level,” then in the Security Settings window, scroll down until you find “Allow META REFRESH.” Disable this option and click OK.

Is meta refresh deprecated?

Use of meta refresh is discouraged by the World Wide Web Consortium (W3C), since unexpected refresh can disorient users.

What is the purpose of refresh meta tag?

HTML allows for the specification of meta information within META tags. A popular use of this technique involves specifying redirections or page reloads within HTML code, rather than relying on HTTP headers to do so (for example, HTTP status code 302 Document moved for redirections).

What is meta refresh in SEO?

A Meta refresh redirect is a client-side redirect. Unlike 301 and 302 redirects that happen on the web server, a meta refresh redirect instructs the web browser to go to a different web page after a specified time span.


1 Answers

I've found that the noscript tag works quite nicely for this. For example, you can place this just after you close the head element:

<noscript>     <meta http-equiv="refresh" content="5;URL=http://www.example.com"> </noscript> 

No need to remove the meta tag with script, since a browser that has script support will ignore everything inside the noscript element.

like image 109
scscsc Avatar answered Oct 14 '22 13:10

scscsc