2 Replies Latest reply on Mar 21, 2010 9:55 PM by StuSchnauzer

    I need to create a download button that detects mac or windows

    richhennosy

      I have mac and windows version of a screensaver. I want the user to click the download button and have either the mac version or windows version download according to what OS is running on the computer. Can anyone advise me on how to accomplish this?

       

      Thanks,

       

      Rich

        • 1. Re: I need to create a download button that detects mac or windows
          370H55V Level 4

          Doing this solely through the download button is an exercise in futility.


          It's much easier to just use two download buttons like this:

          http://www.1001freefonts.com/images/winlogo.pnghttp://www.1001freefonts.com/images/maclogo.png

           

          Or you can use a javascript to detect the browser on your index page, and you can send the visitor to the appropriate downloads page based on the info detected.

           

          A quick search of "browser detection in html" led to to this page: http://www.quirksmode.org/js/detect.html which has a pretty simple detection script.

           

          You'll need to know javascript to write the redirect so your visitors end up in the proper place, but that's why I suggested the buttons. Much simpler, and it leaves the choice up to your visitors, some of whom, like me, quite often download PC software on their Mac (& vice-versa) and pull it over through file sharing. It really all depends which side of the desk I'm sitting at when I find something, how I download a file if I want it. I know the difference between an exe and a dmg. so I know if I'm  downloading the right thing or not.

          • 2. Re: I need to create a download button that detects mac or windows
            StuSchnauzer Level 1

            Assuming your host has PHP available:

             

            <?php

             

            $win = "Windows";

            $mac = "Mac";

             

            $visitor = $_SERVER['HTTP_USER_AGENT'];

             

            if (stristr($visitor, $win)) {

             

            //It's Windoze!

            echo "put your windows button code here";

             

            }

             

            elseif (stristr($visitor, $mac)) {

             

            //It's a Mac!

            echo "put your mac button code here";

             

            }

             

            else {

             

            echo "We only support Windows and Macs for this download";

             

            }

             

            ?>

             

            I'm pretty sure that those two variables at the top cover all OS identification strings in browser ID's, but it'd be worth checking.

             

            ***That code is off the top of my head, and not tested, and will probably break somewhere, but you get the idea.

             

            Message was edited by: StuSchnauzer