about detecting javascript version

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ricardo Garcia

    about detecting javascript version

    hi, i was just wondering about javascript version
    i used to do it putting in the <head>:

    <script type="text/javascript">
    jsver = "1.0";
    </script>
    <script language="JavaS cript1.1">
    jsver = "1.1";
    </script>
    <script language="JavaS cript1.2">
    jsver = "1.2";
    </script>
    <script language="JavaS cript1.3">
    jsver = "1.3";
    </script>
    <script language="JavaS cript1.4">
    jsver = "1.4";
    </script>
    <script language="JavaS cript1.5">
    jsver = "1.5";
    </script>

    and i got in the variable jsver the answer, but i dont think at all this is
    a good method

    Do you know a better way to do it??

    Thanks


  • Andrew Thompson

    #2
    Re: about detecting javascript version

    On Fri, 24 Sep 2004 23:15:55 +0200, Ricardo Garcia wrote:
    [color=blue]
    > <script language="JavaS cript1.1">[/color]
    ...[color=blue]
    > ..i dont think at all this is a good method[/color]

    I agree.
    [color=blue]
    > Do you know a better way to do it??[/color]

    It depends what 'it' is, but the answer is probably
    'feature detection'.

    Get the hang of feature detection, and you will cease to care
    what version of JS the browser reports it is running.

    HTH

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.lensescapes.com/ Images that escape the mundane

    Comment

    • Randy Webb

      #3
      Re: about detecting javascript version

      Ricardo Garcia wrote:
      [color=blue]
      > hi, i was just wondering about javascript version
      > i used to do it putting in the <head>:[/color]

      <--snip-->
      [color=blue]
      > and i got in the variable jsver the answer, but i dont think at all this is
      > a good method
      >
      > Do you know a better way to do it??[/color]

      <script type="text/javascript">
      if (condition){
      //code to execute
      }
      </script>

      Meaning, use the type attribute, forget the language attribute, and test
      for what you want to use in an if statement.

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

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: about detecting javascript version

        Ricardo Garcia wrote:
        [color=blue]
        > hi, i was just wondering about javascript version
        > i used to do it putting in the <head>:
        >
        > <script type="text/javascript">
        > jsver = "1.0";
        > </script>
        > [...]
        > and i got in the variable jsver the answer, but i dont think at all this
        > is a good method[/color]

        Correct. The first "script" element's content is processed by a JavaScript
        1.5 engine and if the UA does not interpret the "JavaScript ..." variants as
        expected, the result will be a false one.
        [color=blue]
        > Do you know a better way to do it??[/color]

        There is no (good) way to do it, use feature detection instead.


        PointedEars
        --
        Experience is life's consolation prize.

        Comment

        Working...