paulgreg
paulgreg

Reputation: 18903

How may I disable an http-equiv refresh in JavaScript?

I'm building a status page which should be refreshed periodically.

So, I've had a http-equiv refresh in the <head> section in order to refresh the page every minute :

<meta http-equiv="Refresh" id="refresh" content="60"/>

But, for browser supporting JavaScript, I would like to send an Ajax request checking if the page should be refreshed or not. And so, I would like to disable that http-equiv refresh in JavaScript (because it's Ajax which will do the work).

I tried to remove the tag using JavaScript/PrototypeJs but that doesn't work :

 $('refresh').remove();

It seems that the browser keep trace of that timer and doesn't take care of that DOM update.

Any idea ?

Upvotes: 4

Views: 4497

Answers (3)

Martin Peck
Martin Peck

Reputation: 11544

I don't think there's a way of disabling the http-equiv refresh.

Is the status page the first page in your app? If not, then why not get the capabilities of the client up front before requesting the status page? If it is then you might have to inject a UI-less page that grabs the capability of the browser and instantly post back to the real status page. All this assumes that you're not willing to use the user agent string in the HTTP Header to get the browser capability.

Upvotes: 0

a paid nerd
a paid nerd

Reputation: 31502

Not exactly sure, but maybe:

<noscript>
    <meta http-equiv="Refresh" id="refresh" content="60"/>
</noscript>

Upvotes: 8

Paul Alexander
Paul Alexander

Reputation: 32367

This would be better handled on the server. There are a number of tools to let you reliably check to see if the browser supports JS (BrowserHawk is one that comes to mind) or you can check the SupportsECMAScript (in ASP.NET) property of the Browser object and write out different code if the browser supports JS.

Upvotes: 0

Related Questions