Cancel meta http-equiv="refresh"?


I have a system where the results appearing on a page are updated periodically by ajax. For people without javascript enabled this is a problem. I have made my system use a meta redirect by default, and intend to have javascript or prototype disable this on page load so people without javascript get a meta redirect, and people with javascript get an ajax update?

<meta http-equiv=“refresh” content=“15;url=/blah.html”></meta>

Problem is - anyone know HOW to disable the meta redirect through javascript or prototype?



<meta http-equiv=“refresh” id=“reload” content="15;url=/

From what I have found, you can’t cancel it. All you can do is create it depending on whether javascript is enabled or not…

I’m not sure whether this is valid, but you “could” use noscript?

<meta http-equiv="refresh" content="10;url=/blah.html" />

yeah i thought of <noscript> but aparently it is only allowed in <body>, not <head>.

Simply place this in the HEAD:

<script type="text/javascript">
window.location = '/for/Those/With/JavaScript/Enabled.html';


Also, note that <noscript> does not always work. If the user’s JavaScript is being disabled by a firewall (i.e. before it even gets to the browser) then the <noscript> tags are totally useless…

Oh I just realised what you meant… U want to totally disable the meta refresh.

You could try something like this: (I’m not sure it will work though)

var m = document.getElementsByTagName('meta'), l=m.length;
while(l--) {
    if(m[l].getAttribute('http-equiv')==='refresh') {


If you give the meta refresh tag an ID of “reload” then simply:


Can you give elements in the HEAD an id???

AFAIK There is no problem with doing this.

Jimmy I tried that yesterday and it didn’t work unfortunately.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
        <title>Untitled Document</title>
        <link rel="stylesheet" type="text/css" media="screen" />
        <style type="text/css"></style>
        <script type="text/javascript">
			window.onload = function() {
				var reload = document.getElementById('reload');
		<meta http-equiv="refresh" content="15;url=/blah.html" id="reload" />

Works for me. (tested the code you posted in FF3)

Oh wait. I see what you mean gRoberts. The actual meta tag is removed from the DOM but the page still refreshes. Eveidently the browser initiates the 15 second refresh as soon as it sees the meta tag and so, even removing it from the DOM will not cancel the refresh…

Chrome, FF3 and IE7/8 redirect to blah.html after 15 seconds for me.

thanks for the replies, none seem to work and they all seem to forward. i assume it’s probably not possible then?

@jonno see #10