2 Copyright (C) 2007 Apple Computer, Inc. All rights reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
7 1. Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 2. Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
13 THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 <script src="WebKitDetect.js"></script>
32 document.getElementById("log").appendChild(document.createTextNode(s));
36 // Test for WebKit-based browser
37 var isWebKit = WebKitDetect.isWebKit();
38 log("Your browser " + (isWebKit ? "uses " : "does not use ") + "WebKit.\r\n");
40 // Test for minimum support
41 var isAtLeast418Dot1 = WebKitDetect.versionIsAtLeast("418.1");
42 log("Your WebKit version is " + (isAtLeast418Dot1 ? "" : "not ") + "at least 418.1.\r\n");
44 // Examine WebKit version
45 var version = WebKitDetect.version();
47 log("Your WebKit version number is " + version.join(".") + ".\r\n");
48 log("Your WebKit version is " + (version.isNightlyBuild ? "" : "not ") + "a nightly build.\r\n");
49 log("Version information: \r\n");
50 for (var p in version)
51 log("\t" + p + ": " + version[p] + "\r\n");
54 // Test for Mobile WebKit browser
55 var isMobile = WebKitDetect.isMobile();
56 var device = WebKitDetect.mobileDevice();
57 log("You are " + (isMobile ? "surfing" : "not surfing") + " Mobile" + (device ? " on " + device : "") + ".\r\n");
59 // Examine Mobile version
60 var mobileVersion = WebKitDetect.mobileVersion();
62 log("Your Mobile version number is " + mobileVersion.join("") + "\r\n");
63 log("Mobile version information: \r\n");
64 for (var p in mobileVersion)
65 log("\t" + p + ": " + mobileVersion[p] + "\r\n");
68 // Test for minimum support
69 var isAtLeast102 = WebKitDetect.mobileVersionIsAtLeast("1C28"); // String found in Settings/General/About/Version
70 log("Your " + device + " version is " + (isAtLeast102 ? "" : "not ") + "at least 1.0.2.\r\n");