Detecting Javascript availability...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dag Sunde

    Detecting Javascript availability...

    We have this web-app that requires Javascript to
    be enabled in the UA (this is okay'ed by our customer).

    Now I want to make a "pre" page before the login screen,
    informing the user that he/she must have JS turned on.

    Problem is that I would prefer to show this page only if
    JS isn't on. (and hence, I have a "Chicken/Egg" problem).

    If neccessary, we can require IE-only as UA.

    Any pointers, suggestions or comments on thisone?

    TIA...

    --
    Dag.


  • BootNic

    #2
    Re: Detecting Javascript availability...

    > "Dag Sunde" <me@dagsunde.co m> wrote:[color=blue]
    > news:7LTte.2287 $qE.580925@juli ett.dax.net....
    >
    > We have this web-app that requires Javascript to
    > be enabled in the UA (this is okay'ed by our customer).
    >
    > Now I want to make a "pre" page before the login screen,
    > informing the user that he/she must have JS turned on.
    >
    > Problem is that I would prefer to show this page only if
    > JS isn't on. (and hence, I have a "Chicken/Egg" problem).
    >
    > If neccessary, we can require IE-only as UA.
    >
    > Any pointers, suggestions or comments on thisone?
    >
    > TIA...[/color]

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>
    Check JavaScript
    </title>
    </head>
    <body>
    <script type="text/javascript">
    function proceed(){
    document.locati on.href = 'http://www.download.co m'
    }
    onload = proceed
    </script>
    <noscript>
    <h1 style="color:re d;text-align:center;">
    JavaScript must be enabled
    </h1>
    <p>
    perhaps some direction on how to enable javascript
    </p>
    </noscript>
    </body>


    --
    BootNic Tuesday, June 21, 2005 8:50 AM

    Humor is just another defense against the universe.
    *Mel Brooks*

    Comment

    • Dag Sunde

      #3
      Re: Detecting Javascript availability...

      "BootNic" <Bootnic@bounce .prodigy.net> wrote in message
      news:K2Ute.2793 $lv.2342@newssv r33.news.prodig y.com...[color=blue][color=green]
      > > "Dag Sunde" <me@dagsunde.co m> wrote:
      > > news:7LTte.2287 $qE.580925@juli ett.dax.net....
      > >
      > > We have this web-app that requires Javascript to
      > > be enabled in the UA (this is okay'ed by our customer).
      > >
      > > Now I want to make a "pre" page before the login screen,
      > > informing the user that he/she must have JS turned on.[/color][/color]
      <snipped/>
      [color=blue]
      > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      > <html>
      > <head>
      > <title>
      > Check JavaScript
      > </title>
      > </head>
      > <body>
      > <script type="text/javascript">
      > function proceed(){
      > document.locati on.href = 'http://www.download.co m'
      > }
      > onload = proceed
      > </script>
      > <noscript>
      > <h1 style="color:re d;text-align:center;">
      > JavaScript must be enabled
      > </h1>
      > <p>
      > perhaps some direction on how to enable javascript
      > </p>
      > </noscript>
      > </body>[/color]

      Thanks a lot!

      I now realize that the <noscript> tag is supported all the way
      to xhtml strict, and all is well.

      --
      Dag.


      Comment

      • Randy Webb

        #4
        Re: Detecting Javascript availability...

        Dag Sunde wrote:
        [color=blue]
        > "BootNic" <Bootnic@bounce .prodigy.net> wrote in message
        > news:K2Ute.2793 $lv.2342@newssv r33.news.prodig y.com...
        >[color=green][color=darkred]
        >>>"Dag Sunde" <me@dagsunde.co m> wrote:
        >>>news:7LTte.2 287$qE.580925@j uliett.dax.net. ...
        >>>
        >>>We have this web-app that requires Javascript to
        >>>be enabled in the UA (this is okay'ed by our customer).
        >>>
        >>>Now I want to make a "pre" page before the login screen,
        >>>informing the user that he/she must have JS turned on.[/color][/color]
        >
        > <snipped/>
        >[color=green]
        >><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        >><html>
        >><head>
        >><title>
        >>Check JavaScript
        >></title>
        >></head>
        >><body>
        >><script type="text/javascript">
        >>function proceed(){
        >>document.loca tion.href = 'http://www.download.co m'
        >>}
        >>onload = proceed
        >></script>
        >><noscript>
        >><h1 style="color:re d;text-align:center;">
        >>JavaScript must be enabled
        >></h1>
        >><p>
        >>perhaps some direction on how to enable javascript
        >></p>
        >></noscript>
        >></body>[/color]
        >
        >
        > Thanks a lot!
        >
        > I now realize that the <noscript> tag is supported all the way
        > to xhtml strict, and all is well.
        >[/color]

        Not as well as you think, and its material to your question.

        Leave the noscript section in the page itself. If script is not
        available (whether not in the UA or disabled) then the page won't be
        redirected and the user will see it. Then, it doesn't matter whether
        noscript is supported or not.

        --
        Randy
        comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
        Answer:It destroys the order of the conversation
        Question: Why?
        Answer: Top-Posting.
        Question: Whats the most annoying thing on Usenet?

        Comment

        • Danny@Kendal

          #5
          Re: Detecting Javascript availability...

          "Dag Sunde" <me@dagsunde.co m> wrote in message
          news:7LTte.2287 $qE.580925@juli ett.dax.net...[color=blue]
          > We have this web-app that requires Javascript to
          > be enabled in the UA (this is okay'ed by our customer).
          >
          > Now I want to make a "pre" page before the login screen,
          > informing the user that he/she must have JS turned on.
          >
          > Problem is that I would prefer to show this page only if
          > JS isn't on. (and hence, I have a "Chicken/Egg" problem).[/color]

          Place the login section in a hidden <div> and then make another unhidden
          <div> which has some suitable message about javascript.

          Once the page loads, hide the message and unhide the login section.


          Comment

          • VK

            #6
            Re: Detecting Javascript availability...

            Using the Occam's raisor (also called KISS in California) :

            (It works for all browsers starting with Netscape 2.0 and including
            Lynx)

            <html>
            <head>
            <title>Welcom e to my company!</title>
            <noscript>
            <meta http-equiv="Refresh"
            content="1;URL= http://www.myserver.co m/noscript.html">
            </noscript>
            <meta http-equiv="Content-Type" content="text/html;
            charset=iso-8859-1">
            </head>

            <body bgcolor="#FFFFF F">
            <p>Login page</p>
            </body>
            </html>

            Comment

            • Dag Sunde

              #7
              Re: Detecting Javascript availability...

              "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
              news:8_mdnWRvgM GIvCXfRVn-vw@comcast.com. ..[color=blue]
              > Dag Sunde wrote:[/color]
              <snipped/>[color=blue][color=green]
              > > I now realize that the <noscript> tag is supported all the way
              > > to xhtml strict, and all is well.
              > >[/color]
              >
              > Not as well as you think, and its material to your question.
              >
              > Leave the noscript section in the page itself. If script is not
              > available (whether not in the UA or disabled) then the page won't be
              > redirected and the user will see it. Then, it doesn't matter whether
              > noscript is supported or not.[/color]

              I did it like below, can you see any problems with that?

              <?xml version='1.0' encoding='iso-8859-1' ?>
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
              <html xmlns="http://www.w3.org/1999/xhtml">
              <head>
              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
              <title>RegWeb - Sjekker JavaScript</title>
              <link type="text/css" rel="stylesheet " href="styles/ekstranett.css" />
              <script type="text/javascript">
              function fwdOnScriptPres ent() {
              document.locati on.href = './pages/UASettings.asp' ;
              }
              </script>
              </head>

              <body onload="fwdOnSc riptPresent();" >
              <noscript>
              <h2 style="color:re d;">
              JavaScript must be supported, or turned on...
              </h2>
              <h3>How to proceed:</h3>
              <p>yada, yada...</p>
              </noscript>
              </body>
              </html>

              --
              Dag.


              Comment

              • Randy Webb

                #8
                Re: Detecting Javascript availability...

                Dag Sunde wrote:
                [color=blue]
                > "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
                > news:8_mdnWRvgM GIvCXfRVn-vw@comcast.com. ..
                >[color=green]
                >>Dag Sunde wrote:[/color]
                >
                > <snipped/>
                >[color=green][color=darkred]
                >>>I now realize that the <noscript> tag is supported all the way
                >>>to xhtml strict, and all is well.
                >>>[/color]
                >>
                >>Not as well as you think, and its material to your question.
                >>
                >>Leave the noscript section in the page itself. If script is not
                >>available (whether not in the UA or disabled) then the page won't be
                >>redirected and the user will see it. Then, it doesn't matter whether
                >>noscript is supported or not.[/color]
                >
                >
                > I did it like below, can you see any problems with that?
                >
                > <?xml version='1.0' encoding='iso-8859-1' ?>
                > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
                > <html xmlns="http://www.w3.org/1999/xhtml">
                > <head>
                > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                > <title>RegWeb - Sjekker JavaScript</title>
                > <link type="text/css" rel="stylesheet " href="styles/ekstranett.css" />
                > <script type="text/javascript">
                > function fwdOnScriptPres ent() {
                > document.locati on.href = './pages/UASettings.asp' ;
                > }
                > </script>
                > </head>
                >
                > <body onload="fwdOnSc riptPresent();" >
                > <noscript>[/color]

                Remove the noscript tag.
                [color=blue]
                > <h2 style="color:re d;">
                > JavaScript must be supported, or turned on...
                > </h2>
                > <h3>How to proceed:</h3>
                > <p>yada, yada...</p>
                > </noscript>[/color]

                Remove the closing noscript tag.
                [color=blue]
                > </body>
                > </html>
                >[/color]

                Consider this scenario:

                The UA doesn't support redirection via script. Whether it doesn't
                support .href or the location object. The script will fail, yet the user
                won't see the noscript section. Leaving it out leaves it readable by
                anyone, for whatever reason, that doesn't get redirected.

                There is an ongoing thread at the moment entitled "Problems with JS
                turned off" that discusses this very point.

                --
                Randy
                comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

                Comment

                • Randy Webb

                  #9
                  Re: Detecting Javascript availability...

                  VK wrote:
                  [color=blue]
                  > Using the Occam's raisor (also called KISS in California) :
                  >
                  > (It works for all browsers starting with Netscape 2.0 and including
                  > Lynx)[/color]

                  Are you positive about that? I'm not.
                  [color=blue]
                  > <html>
                  > <head>
                  > <title>Welcom e to my company!</title>
                  > <noscript>
                  > <meta http-equiv="Refresh"
                  > content="1;URL= http://www.myserver.co m/noscript.html">[/color]

                  IE6 explicitly allows the disabling of META Refresh. If the browser is
                  Meta disabled and script disabled your user will be staring at a blank
                  screen (test it).

                  Also, the noscript element is not allowed in the head section anyway.
                  And what a browser does with invalid HTML is a guess at best.

                  --
                  Randy
                  comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

                  Comment

                  • Thomas 'PointedEars' Lahn

                    #10
                    Re: Detecting Javascript availability...

                    Dag Sunde wrote:
                    [color=blue]
                    > "Randy Webb" <HikksNotAtHome @aol.com> wrote [...]:[color=green]
                    >> Dag Sunde wrote:[/color]
                    > <snipped/>[color=green][color=darkred]
                    >> > I now realize that the <noscript> tag is supported all the way
                    >> > to xhtml strict, and all is well.[/color]
                    >>
                    >> Not as well as you think, and its material to your question.
                    >>
                    >> Leave the noscript section in the page itself. If script is not
                    >> available (whether not in the UA or disabled) then the page won't be
                    >> redirected and the user will see it. Then, it doesn't matter whether
                    >> noscript is supported or not.[/color]
                    >
                    > I did it like below, can you see any problems with that?[/color]

                    Alas, I can see plenty of them.
                    [color=blue]
                    > <?xml version='1.0' encoding='iso-8859-1' ?>
                    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
                    > <html xmlns="http://www.w3.org/1999/xhtml">[/color]

                    Whatever M$ tells you, Internet Explorer (IE) does not support XHTML. I
                    do hope that you don't serve this XHTML as text/html to workaround that,
                    but as application/xhtml+xml and serve an HTML alternative as text/html
                    to IE and other non-XHTML UAs.

                    <http://www.hixie.ch/advocacy/xhtml>

                    Although it is Valid markup, there is no point whatsoever in declaring XHTML
                    1.0 Transitional. Like the man said, you can't eat the cake and have it.
                    Either you want clean markup (e.g. to speed up the parsing process) or you
                    don't want it. If the former, declare HTML 4.01 Strict, XHTML 1.0 Strict
                    or even XHTML 1.1 Strict if you have to; if the latter, declare HTML 4.01
                    Transitional.
                    [color=blue]
                    > <head>
                    > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
                    > />[/color]

                    The character declaration meta element is redundant in valid XHTML served
                    with the appropriate Content Type. An XML parser has to determine the
                    encoding of a document before building the parse tree; a character
                    declaration of this kind simply is too late at this line.
                    [color=blue]
                    > [...]
                    > <link type="text/css" rel="stylesheet " href="styles/ekstranett.css" />[/color]

                    This alone is not supposed to work in correctly served XHTML. XHTML
                    documents are the result of an application of XML and so an XML processing
                    instruction (PI) before the root element (here: HTML) is required to
                    specify the used stylesheet. This means you either specify the CSS
                    resource in the PI, or provide a `style' element with an `id' attribute
                    value while referring to the fragment identifier in the PI. The former
                    is recommended to avoid declaring style content as CDATA or to escape
                    markup characters (e.g. `>', both CSS child selector and XML TAGC
                    delimiter).

                    <http://www.w3.org/TR/xhtml1/guidelines.html #C_14>
                    [color=blue]
                    > <script type="text/javascript">
                    > function fwdOnScriptPres ent() {
                    > document.locati on.href = './pages/UASettings.asp' ;
                    > }
                    > [...]
                    > <body onload="fwdOnSc riptPresent();" >[/color]

                    The function is redundant so far (and therefore a little bit inefficient
                    compared to the alternative): the one line could have been easily included
                    in the event handler attribute value.

                    `document.locat ion' is deprecated long since. Use `window.locatio n' or
                    `location' if you can be sure that in the targeted UAs the `window' property
                    would refer to the Global Object (you can save one lookup this way and your
                    code becomes shorter).

                    No syntax errors here, but you should be aware that if you include e.g.
                    certain comparison operators to the script without either declaring script
                    content as CDATA (character data) or escaping those operators you will run
                    into trouble; the default content type of the `script' element is PCDATA
                    (parsed CDATA): e.g. an undeclared `<' is considered an STAGO delimiter.
                    That's why it is recommended to include script files (containing unescaped
                    code without CDATA declarations, of course) instead.

                    <http://www.w3.org/TR/xhtml1/diffs.html#h-4.8>
                    [color=blue]
                    > <noscript>[/color]

                    There is no point in using the `noscript' element in this document, unless
                    the above code is just an example and you want a timed redirection. If not,
                    just let the script code execute within the `head' element and a JS capable
                    UA will never reach this line.
                    [color=blue]
                    > <h2 style="color:re d;">[/color]

                    <http://www.w3.org/QA/Tips/color>
                    [color=blue]
                    > JavaScript must be supported, or turned on...[/color]

                    The assumption "as is" is wrong and based on a misconception. Although
                    non-compliant regarding the HTML 4.01 Specification, many user agents tend
                    to ignore the value of the `type' attribute of the `script' element and
                    use the default scripting language always. If, for some strange reason,
                    the default scripting language of a UA would be not JS, JS could be
                    supported and this section be displayed anyway. I have yet to see such
                    an UA, though.
                    [color=blue]
                    > </h2>
                    > <h3>How to proceed:</h3>[/color]

                    <http://www.w3.org/QA/Tips/headings>
                    [color=blue]
                    > [...]
                    > </noscript>
                    > [...][/color]


                    HTH

                    PointedEars
                    --
                    Multiple exclamation marks are a sure sign of a diseased mind.
                    -- Terry Pratchett

                    Comment

                    • Thomas 'PointedEars' Lahn

                      #11
                      Re: Detecting Javascript availability...

                      VK wrote:
                      [color=blue]
                      > Using the Occam's raisor (also called KISS in California) :[/color]

                      I'm afraid it's more stupid than simple.
                      [color=blue]
                      > (It works for all browsers starting with Netscape 2.0 and including
                      > Lynx)
                      >
                      > [gibberish code][/color]

                      Certainly not. It is far from being Valid HTML, let alone a usable
                      document.


                      PointedEars

                      Comment

                      • Dag Sunde

                        #12
                        Re: Detecting Javascript availability...

                        "Thomas 'PointedEars' Lahn" <PointedEars@we b.de> wrote in message
                        news:1283849.D6 dSQf363U@Pointe dEars.de...[color=blue]
                        > Dag Sunde wrote:
                        >[color=green]
                        >> "Randy Webb" <HikksNotAtHome @aol.com> wrote [...]:[/color][/color]

                        <snipped />

                        Thank you for a long list of explanations to the different issues,
                        both of you...

                        some of it was sloppyness in my example, some of it was completely new
                        to me, and some it is hard to believe.

                        I'll try to absorb it during the next week (I'm on vacation :-)).

                        Tank you.

                        --
                        Dag.


                        Comment

                        Working...