[thelist] Speaking of detecting: howto detect Javascript on/off?

James Aylard evolt at equilon-mrc.com
Wed Mar 14 11:20:55 CST 2001


> The only way I can think of is having a page with an onLoad() send the
> browser to the javascript pages, and a META refresh tag that would fire
> send them to non-jaascript pages in the event the onLoad() doesn't happen
> (they have javascript turned off). Is this the accepted way of doing it?
> there alternatives?

    I've developed a page that does something similar to this (it uses ASP,
so I haven't posted it to my members.evolt.org site -- a future project).
You don't need to use the onload event handler, however; just put your
script right at the top of your page. The moment the scripting engine hits
it, it will redirect the page. Then set a meta refresh of a couple of
seconds (in case the browser is slow at parsing the javascript) to handle
the javascript-disabled browsers, e.g.:

<script type="text/javascript">
    window.location.href = "target.asp?js=true" ;
  // -->
<meta http-equiv="refresh" content="2; URL=target.asp?js=false">

    In my example page, I set a value in the querystring (js=true or
js=false) which I grabbed in ASP and then took action accordingly. You could
also redirect to two different pages. And if you want to be thorough, you
can add a link for those browsers that don't even support meta redirects.

James Aylard

More information about the thelist mailing list