Thursday, February 17, 2011

How can I update meta refresh from javascript when using asynchronous calls?

I have a system that uses a meta refresh to a logout page, which cleans up after idle users. (Don't worry, the server also times out the session)

I started doing some operations via ajax (not really xml, but that's beside the point). I can run javascript returned from the async request, so I'm wondering if it's possible to reset the meta refresh on the page so that it has a longer timeout. The usual setTimeout calls just add a new timeout, but do they replace the meta timeout?

From stackoverflow
  • No. The meta tag is interpreted when the page loads as though it were an actual HTTP header, and post-load changes have no affect on it.

    You're better off ditching the meta refresh, and relying entirely on JavaScript to reload the page when appropriate. If you must support clients without scripting, then default to a no-script page utilizing meta refresh combined with a JS redirect to script-enabled (meta refresh free) page for users who can take advantage of it.

0 comments:

Post a Comment