最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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 ?

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 ?

Share Improve this question edited May 11, 2009 at 20:45 paulgreg asked May 11, 2009 at 20:38 paulgregpaulgreg 18.9k18 gold badges48 silver badges56 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 8

Not exactly sure, but maybe:

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

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 es 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.

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.

发布评论

评论列表(0)

  1. 暂无评论