How to run the JavaScript if above version?

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

    How to run the JavaScript if above version?

    E.g. I only want if my browser support JavaScript 1.9


    <script type="text/javascript" language="JavaS cript1.9">
    alert("Hello");
    </script>

  • Peter Michaux

    #2
    Re: How to run the JavaScript if above version?

    On Jul 2, 7:47 pm, howa <howac...@gmail .comwrote:
    E.g. I only want if my browser support JavaScript 1.9
    >
    <script type="text/javascript" language="JavaS cript1.9">
    alert("Hello");
    </script>
    Why do you want to do that?

    Peter

    Comment

    • howa

      #3
      Re: How to run the JavaScript if above version?

      The above is just an example...

      For example, if I want to take some advance features of JavaScript
      version, I don't want older client to see the syntax error.


      On 7$B7n(B3$BF| (B, $B>e8a(B11$B ;~(B18$BJ,(B , Peter Michaux <petermich...@g mail.comwrote:
      On Jul 2, 7:47 pm, howa <howac...@gmail .comwrote:
      >
      E.g. I only want if my browser support JavaScript 1.9
      >
      <script type="text/javascript" language="JavaS cript1.9">
      alert("Hello");
      </script>
      >
      Why do you want to do that?
      >
      Peter

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: How to run the JavaScript if above version?

        howa wrote:
        E.g. I only want if my browser support JavaScript 1.9
        >
        <script type="text/javascript" language="JavaS cript1.9">
        alert("Hello");
        </script>
        JavaScript 1.9 -- that would be Firefox 4, would it not?

        Anyhow, MDC explains how to do it for JavaScript 1.8 as
        supported in Firefox 3:

        <script type="applicati on/javascript;vers ion=1.8">
        ... your code ...
        </script>

        <http://developer.mozil la.org/en/docs/New_in_JavaScri pt_1.8>

        And now your transfer effort, please.


        PointedEars
        --
        var bugRiddenCrashP ronePieceOfJunk = (
        navigator.userA gent.indexOf('M SIE 5') != -1
        && navigator.userA gent.indexOf('M ac') != -1
        ) // Plone, register_functi on.js:16

        Comment

        • RobG

          #5
          Re: How to run the JavaScript if above version?

          On Jul 3, 3:50 pm, Peter Michaux <petermich...@g mail.comwrote:
          On Jul 2, 9:40 pm, RobG <rg...@iinet.ne t.auwrote:
          [...]
          Use standard feature detection and add the desired functionality to
          UAs that lack it:
          >
            if (typeof Array.prototype .reduce != 'function') {
              // add your own reduce method
            }
          >
          Set your feature detection for say version 1.5 or maybe 1.3 and you
          don't care what ECMAScript implementation is being used.
          >
          I'm not quite sure how that avoids syntax errors.
          I think you misunderstood my point, which probably means it was poorly
          stated. I meant do feature detection for features introduced after
          1.5 or 1.3 as appropriate.
          You could test for
          features of the language that are in JavaScript 1.9. If those features
          are present then only load script files that would other syntax error
          in browsers missing JavaScript 1.9 support.
          That might be called "language version inference". :-)


          --
          Rob

          Comment

          • Bart Van der Donck

            #6
            Re: How to run the JavaScript if above version?

            Peter Michaux wrote:
            >>>howa wrote:
            >>>><script type="text/javascript" language="JavaS cript1.9">
            >>>>        alert("Hello");
            >>>></script>
            I don't know if there is a way to do what you want with some technique
            like the "language" attribute for recent versions of JavaScript. I've
            never bothered trying.
            But my curiosity remains.
            Maybe worth a glance:


            The OP's idea should work in theory; but I think it's a bit reckless
            to fully lean on the version as specified in the language-attribute.
            For example, how would this relate to Microsoft's JScript (eg. my
            MSIE7 only claims to support javascript up to 1.3.).

            I would prefer the usual object detection as well.

            --
            Bart

            Comment

            Working...