We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15338
    • 3 Posts
    I made a snippet with the code:

    <?php
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0') !== FALSE) {
        echo 'You have Internet Explorer 6';
    }
    
    else {
        echo 'DYou have something else';
    }
    ?>


    i call for the code by adding [[ie]] to my code, but here is the problem, when i visit my page i don’t se "You have Internet Explorer 6" even if I am using IE6.

    Maybe there is a easy solution for my problems?

    Thanks
      • 3749
      • 24,544 Posts
      Quote from: kanske at May 25, 2008, 07:14 PM


      <?php
      if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0') !== FALSE) {
          echo 'You have Internet Explorer 6';
      }
      
      else {
          echo 'You have something else: ';
          echo $_SERVER['HTTP_USER_AGENT'];
      }
      ?>


      Try the above instead, you’ll see what user agent is being reported. You might have to change it to just ’MSIE 6’

      It’s also likely that you can achieve what you want more easily with conditional comments: http://virtuelvis.com/archives/2004/02/css-ie-only. Another method that I like a lot can be found here: http://www.positioniseverything.net/articles/cc-plus.html.

      Hope this helps.
      Bob
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 15338
        • 3 Posts
        In IE6the script is reporting: Mozilla/5.0 (Windows; U; Windows NT 5.1; sv-SE; rv:1.9) even if I change it tå MSIE 6.

        I have tried the code and it works as i should when i don’t use it as a snippet.

        The reson why i wan’t to do this is because IE6 is so old and crappy and when a visitor with ie6 visits my homepage they will recieve a message that tells him to upgrade/change browser. If there is any easier way to do this, feel free to help me smiley

        Thank you for you help so far!
          • 3749
          • 24,544 Posts
          <!--[if lte IE 6]>
          <p>You need to upgrade your browser</p>
          <![endif]-->



          This targets anyone with IE6 or older (lte is for "less than or equal"). If you only want to target IE6, just leave out the "lte" altogether.

          IE6 users will still see the rest of the page. To avoid that you can put another conditional comment around the rest:

          <!--[if (gt IE6) | (!IE)]>
          <p>Page main content</p>
          <![endif]-->


          I haven’t tested this second part and I wouldn’t count on it working in all browsers. Most of us still use specific code to make our pages work properly in IE6 because many of the people using it haven’t a clue about how to upgrade and some (e.g. students in computer labs) don’t have the authority to upgrade.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 5340
            • 1,624 Posts
            If you cache this snippet you my get into problems.
            If the first user after clearing the cache uses IE6, the second user using Firefox will get the:

            <p>You need to upgrade your browser</p>

            So do not cache this snippet. Or use CSS
              • 15338
              • 3 Posts
              Quote from: xpix at May 26, 2008, 10:53 AM

              If you cache this snippet you my get into problems.
              If the first user after clearing the cache uses IE6, the second user using Firefox will get the:

              <p>You need to upgrade your browser</p>

              So do not cache this snippet. Or use CSS

              Thank you! That was the problem tongue It works great now laugh