Book Image

MooTools 1.2 Beginner's Guide

Book Image

MooTools 1.2 Beginner's Guide

Overview of this book

MooTools is a simple-to-use JavaScript library, ideal for people with basic JavaScript skills who want to elevate their web applications to a superior level. If you're a newcomer to MooTools looking to build dynamic, rich, and user-interactive web site applications this beginner's guide with its easy-to-follow step-by-step instructions is all you need to rapidly get to grips with MooTools.
Table of Contents (14 chapters)
MooTools 1.2 Beginner's Guide
Credits
About the Authors
About the Reviewer
Preface

Time for action—using Browser.Platform to customize SuperSoftware's download page


We'll use the Browser.Platform property to detect what platform the client uses so that we can tailor the page based on the user's operating system.

  1. Let's figure out what the user's operating system is and put it in a variable called userPlatform. The values will be of a string data type and will be of the following values: win (for Windows), mac (for Mac OS), linux (for Linux machines), ipod (Apple iPhone and Apple iPod touch), and other (platform can't be detected or is unrecognized).

    window.addEvent('domready', function(){
    var userPlatform = Browser.Platform.name;
    });
    
  2. Next, we build a function called pageCustomizer that will customize our page. We'll pass userPlatform (later on) to it so that it knows what platform it'll be working with. Let's set that up now:

    window.addEvent('domready', function(){
    var userPlatform = Browser.Platform.name;
    // Customizes download page depending on client's platform
    var pageCustomizer...