[Javascript] Javascript detection

Stephan Wehner stephanwehner at gmail.com
Mon Jan 1 23:48:14 CST 2007


On 1/1/07, tedd <tedd at sperling.com> wrote:
> At 1:37 AM +0000 1/2/07, David Dorward wrote:
> >On Mon, Jan 01, 2007 at 08:31:09PM -0500, Matt Warden wrote:
> >>  On 1/1/07, David Dorward <david at dorward.me.uk> wrote:
> >>  >So - how is it useful to know if the client supports JavaScript or
> >>  >not? The page works either way.
> >>
> >>  Perhaps we can skip the interview and just help answer the OP's
> question.
> >
> >Perhaps if the OP explains his thinking then:
> >
> >(a) We can learn something
> >
> >or
> >
> >(b) We can suggest a better solution
> >
> >This is a *discussion* list isn't it?
> >
> >--
> >David Dorward                                      http://dorward.me.uk
>
> David et al:
>
> To explain what I'm trying to do is probably too complicated for my
> limited communication skills.
>
> The original post that started me on this investigation was simply
> "How does one take the value of a javascript variable and carry it
> forward to the next page?" However, no one was able to provide an
> answer, other than using cookies and I don't want to do that.
> However, I believe that it can be done otherwise and that's what I am
> trying to accomplish.

I've come up with a way to accomplish as much of what I understand the
ambition to be; I've been able to see it working on my rather outdated
browser, Mozilla 1.3.1 - Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.3.1) Gecko/20030425.

The idea is to set the base-href to different values, depending on
whether javascript is enabled or not. Here is a simple test file.

<html>
  <head>
    <noscript>
      <base href="file:///tmp/noscript/">
    </noscript>

    <script type='text/javascript'>
      <!--
        document.write(' <base href="file:///tmp/script/"> ')
      -->
    </script>

  </head>

   <body>

   Go to the <a href="a.html">exciting and telling</a> page.

  </body>

</html>

I use file:///tmp since I don't want to set up a server for this.

Now I create two directories /tmp/script and /tmp/noscript and put a
file a.html in each.
One says "no script", the other says "script".

Depending on whether I enable javascript or not, I am taken to the correct page.

(I often think I'm glad I am not a web-browser, having to process all
this stuff.)

Does it work in other browsers? Does it do what Tedd wants?

Stephan



More information about the Javascript mailing list