Can someone help me with a Javascript problem?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 2MuchMark
    Mark of 2Much.net
    • Aug 2004
    • 50977

    #1

    Can someone help me with a Javascript problem?

    So it's Friday night and my programmers are off partying and getting laid, and I'm staying in and trying to better my smarts with a little website work, and I'm stuck.

    I have a line in my page that looks just like this, complete the comment tags.

    <!-- one two three four -->

    The above appears in the body of the page.

    What I want to do is detect if the user on the web page is using Internet Explorer, and if so, to change the code above so that it looks like this:

    <!-- two three four -->

    with the "one" removed.

    Any help is appreciated!
  • clickity click
    So Fecking Bummed
    • Aug 2014
    • 3682

    #2
    Fuck Javascript.

    Comment

    • freecartoonporn
      Confirmed User
      • Jan 2012
      • 7683

      #3
      you want to detect users browser or just change
      this
      <!-- one two three four -->

      to

      <!-- two three four -->

      ?
      SSD Cloud Server, VPS Server, Simple Cloud Hosting | DigitalOcean

      Comment

      • marlboroack
        So Fucking Banned
        • Jul 2010
        • 9327

        #4
        and fuck you

        Comment

        • 2MuchMark
          Mark of 2Much.net
          • Aug 2004
          • 50977

          #5
          Originally posted by freecartoonporn
          you want to detect users browser or just change
          this
          <!-- one two three four -->

          to

          <!-- two three four -->

          ?

          Hiya,

          I want to do this : If Browser = IE then

          <!-- two three four -->

          Else

          <!-- one two three four -->

          Comment

          • Paul&John
            Confirmed User
            • Aug 2005
            • 8643

            #6
            Here is one type of code: javascript - jQuery: check if user is using IE - Stack Overflow

            Code:
            var ua = window.navigator.userAgent;
            var msie = ua.indexOf("MSIE ");
            
            if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
                        alert("Its IE");
                    else                 
                        alert("Its NOT IE");
            Use coupon 'pauljohn' for a $1 discount at already super cheap NameSilo!
            Anal Webcams | Kinky Trans Cams Live | Hotwife XXX Tube | Get your Proxies here

            Comment

            • Video-Post
              Selling short ICQ numbers
              • Dec 2001
              • 1118

              #7
              Well, here you go - put this between the HEAD and BODY tags:

              Code:
              <script>
              function myFunction() {
              var ua = window.navigator.userAgent;
              var msie = ua.indexOf("MSIE ");
              if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
              document.getElementById("brchk").innerHTML = "<!-- two three four -->";
              else                 
              document.getElementById("brchk").innerHTML = "<!-- one two three four -->";
              }
              </script>

              Then insert this in the body tag to trigger the function above once:

              Code:
              <body onload="myFunction()">

              Finally, put this between the HTML tags in your document:

              Code:
              <span id="brchk"><!-- lets check --><span>

              Comment

              • freecartoonporn
                Confirmed User
                • Jan 2012
                • 7683

                #8
                what ^^ said will do it.
                SSD Cloud Server, VPS Server, Simple Cloud Hosting | DigitalOcean

                Comment

                • ravo
                  Confirmed User
                  • Jun 2001
                  • 5461

                  #9
                  Originally posted by MarkPrince
                  ... my programmers are off partying and getting laid, ...
                  LOL, rarely hear that about programmers....
                  AdultAdBroker - Buy and Sell Your Flat Rate Banners, Links, Tabs, Pops, Email Clicks and Members' Area Traffic - updated May 2026

                  Comment

                  • WorstDrug
                    Registered User
                    • Jun 2015
                    • 11

                    #10
                    You're better off handling this logic server-side, saving client-side resources (and making your website a tiny bit faster). I'm guessing that you use PHP since you're asking for technical help on, well, not the most technical forum on the web? :-p
                    Porn Video Compilations: The Worst Drug

                    Comment

                    • k0nr4d
                      Confirmed User
                      • Aug 2006
                      • 9231

                      #11
                      Maybe this will help

                      https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx
                      Mechanical Bunny Media
                      Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

                      Comment

                      • Barry-xlovecam
                        It's 42
                        • Jun 2010
                        • 18083

                        #12
                        We capture the User-Agent: headers then output the correct URI for that browser -- I refer to it as the Internet Brick (IE). ** CSS notation is just if statements in the page source ** These headers are sent with the first server request by default. However, that sort of JavaScript would catch when forged headers are sent by a scraping browser that could be useful to verify ...

                        Comment

                        • Video-Post
                          Selling short ICQ numbers
                          • Dec 2001
                          • 1118

                          #13
                          Originally posted by Video-Post
                          Well, here you go - put this between the HEAD and BODY tags:

                          Code:
                          <script>
                          function myFunction() {
                          var ua = window.navigator.userAgent;
                          var msie = ua.indexOf("MSIE ");
                          if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
                          document.getElementById("brchk").innerHTML = "<!-- two three four -->";
                          else                 
                          document.getElementById("brchk").innerHTML = "<!-- one two three four -->";
                          }
                          </script>

                          Then insert this in the body tag to trigger the function above once:

                          Code:
                          <body onload="myFunction()">

                          Finally, put this between the HTML tags in your document:

                          Code:
                          <span id="brchk"><!-- lets check --><span>
                          Sorry, small change - put the first code between the head tags instead of between the HEAD and BODY tags. It should work anyway but better stick to the norm.

                          Comment

                          • Video-Post
                            Selling short ICQ numbers
                            • Dec 2001
                            • 1118

                            #14
                            Oh and I forgot the slash in the span tag. You can simply use:

                            Code:
                            <span id="brchk"></span>
                            ...as anything in between the span tags will be changed according to the browser used when the page has loaded. You can also let it execute in real-time as the page renders in the browser.

                            Comment

                            • Video-Post
                              Selling short ICQ numbers
                              • Dec 2001
                              • 1118

                              #15
                              If you want do it in real time, simply paste the code below somewhere inside the HTML tags:

                              Code:
                              <span id="brchk"><span>
                              <script>
                              var ua = window.navigator.userAgent;
                              var msie = ua.indexOf("MSIE ");
                              if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
                              document.getElementById("brchk").innerHTML = "<!-- two three four -->";
                              else                 
                              document.getElementById("brchk").innerHTML = "<!-- one two three four -->";
                              </script>
                              Since it's just a quick check, this is probably the easiest and most sensible approach.

                              Comment

                              • Video-Post
                                Selling short ICQ numbers
                                • Dec 2001
                                • 1118

                                #16
                                Inside the BODY tags to be more precise.

                                Comment

                                Working...