who knows javascript?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pete-KT
    Workin With The Devil
    • Oct 2004
    • 51532

    #1

    who knows javascript?

    Im trying to figure out a way to tell it that if its using IE to use one script but if its useing any other browser to use a different script, I tried usuing regular if else statements but doesnt seem like java likes those
  • MoviesBucks
    Registered User
    • Nov 2006
    • 31

    #2
    if(navigator.AppName== 'Netscape') - it's netscape, seamonkey,firefox or whatever, otherwise it's 99% IE
    The only legal way to earn millions

    Comment

    • Pete-KT
      Workin With The Devil
      • Oct 2004
      • 51532

      #3
      thats of no help to call the JS in html file

      Comment

      • Calvinguy
        Confirmed User
        • Oct 2002
        • 1752

        #4
        What you are describing sounds like bad programing. You should test if a given function is supported by the browser instead of testing what browser is used.

        Comment

        • Pete-KT
          Workin With The Devil
          • Oct 2004
          • 51532

          #5
          what i wanna do calvin is in the html tell it if its IE use this .js else use the other .js

          Comment

          • psili
            Confirmed User
            • Apr 2003
            • 5526

            #6
            Use a server side script to write the .js include:

            if($_SERVER["HTTP_USER_AGENT"] == "so and so")
            echo "this.js";
            else
            echo "that.js";

            Or, have your .js file alias to a server side script that does the same thing internally.

            Otherwise, I tend to agree with Calvilnguy, that's it'd be better to just write cross-platform JS scripts.
            Your post count means nothing.

            Comment

            • Pete-KT
              Workin With The Devil
              • Oct 2004
              • 51532

              #7
              Thanks psili

              Comment

              • DaddyHalbucks
                A freakin' legend!
                • Feb 2004
                • 18975

                #8
                Is javascript really necessary?
                Boner Money

                Comment

                • polle54
                  Confirmed User
                  • Jul 2004
                  • 4626

                  #9
                  Originally posted by psili
                  Use a server side script to write the .js include:

                  if($_SERVER["HTTP_USER_AGENT"] == "so and so")
                  echo "this.js";
                  else
                  echo "that.js";

                  Or, have your .js file alias to a server side script that does the same thing internally.

                  Otherwise, I tend to agree with Calvilnguy, that's it'd be better to just write cross-platform JS scripts.
                  are you sure you mean echo????

                  that's for writing shit in php
                  ICQ# 143561781

                  Comment

                  • psili
                    Confirmed User
                    • Apr 2003
                    • 5526

                    #10
                    Originally posted by polle54
                    are you sure you mean echo????

                    that's for writing shit in php
                    Just meant "echo" the include line to the browser... guess it was more pseudo code I threw in there, than anything else.
                    Your post count means nothing.

                    Comment

                    • SmokeyTheBear
                      ►SouthOfHeaven
                      • Jun 2004
                      • 28609

                      #11
                      why not just put the 2 javascript together in one file in sep functions..

                      this would go in body tag or head tag

                      Code:
                      <script src=detect.js></script>
                      <script>
                      var browser_type=navigator.appName
                      var browser_version=parseInt(navigator.appVersion)
                      
                      //if IE 4+
                      if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4){
                      document.write("- press any keyboard key to skip to the next picture -<br>");
                      ie();
                      }
                      else
                      {
                      
                      notie();
                      }
                      </script>
                      This would go inside detect.js
                      Code:
                      function ie() {
                      
                      alert('Your using internet explorer');
                      
                      }
                      function notie() {
                      
                      alert('Your not using internet explorer');
                      
                      }
                      hatisblack at yahoo.com

                      Comment

                      • RazorSharpe
                        Confirmed User
                        • Aug 2001
                        • 2238

                        #12
                        hi Pete,

                        Try this:

                        http://www.cdnetworx.com/detect.zip

                        basically, you put the code that is in example.html into the page you want the detection on. Put your firefox javascript into fire.js and your ie specific js into ie.js

                        should work ... if you have questions, my icq is 125-48-32-18

                        cheers ...
                        Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

                        Comment

                        • Pete-KT
                          Workin With The Devil
                          • Oct 2004
                          • 51532

                          #13
                          Thanks Razor and Smokey

                          Comment

                          • RazorSharpe
                            Confirmed User
                            • Aug 2001
                            • 2238

                            #14
                            Originally posted by Pete-KT
                            Thanks Razor and Smokey
                            no worries mate, glad i could help

                            ...
                            Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

                            Comment

                            Working...