views:

961

answers:

3

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 ?

A: 

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.

Paul Alexander
Supporting JavaScript is not the same as having it enabled.
epascarello
That's true - that's why I referenced a tool like BrowserHawk which actually tests the target browser.
Paul Alexander
+6  A: 

Not exactly sure, but maybe:

<noscript>
    <meta http-equiv="Refresh" id="refresh" content="60"/>
</noscript>
a paid nerd
My understanding was the noscript only worked in the body.
Martin Peck
I'm not sure if that's really XHTML valid but seems to work !
paulgreg
Hey - it works (just tried it in IE8 with scripting on and off). +1 for this answer.
Martin Peck
Yes, thanks a lot ! Here's the result : http://build-status.appspot.com/?app_name=your_project_name
paulgreg
It would be even better if I may found a way to be W3 compliant. :)
paulgreg
you could also try removing the tag's node from the DOM via JS.
Tracker1
It's what I tried first (see my question) but browser doesn't take care of that modification.
paulgreg
I almost downvoted this answer, but then I tested it and found out it actually works (at least on IE5, IE6, Safari 4, Firefox, and Chrome). It looks to me like the W3C needs to get with it on this one.
Joey Adams
A: 

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.

Martin Peck