Docs: Added section about Browser.ie vs. Browser.modernie.
[mootools.git] / Docs / Browser / Browser.md
blob4b70da42c04edb9a0c4014c824c75171604b48ad
1 Object: Browser {#Browser}
2 ==========================
4 Some browser properties are attached to the Browser Object for browser and platform detection.
6 Browser.Features {#Browser:Browser-Features}
7 --------------------------------------------
9 * Browser.Features.xpath - (*boolean*) True if the browser supports DOM queries using XPath.
10 * Browser.Features.air - (*boolean*)  True if the browser supports AIR.
11 * Browser.Features.query - (*boolean*) True if the browser supports querySelectorAll.
12 * Browser.Features.json - (*boolean*) True if the browser has a native JSON object.
13 * Browser.Features.xhr - (*boolean*) True if the browser supports native XMLHTTP object.
15 Browser.Plugins {#Browser:Browser-Plugins}
16 ------------------------------------------
18 * Browser.Plugins.Flash - (*object*) - An object with properties corresponding to the `version` and `build` number of the installed Flash plugin. Note: if flash is not installed, both `Browser.Plugins.Flash.version` and `Browser.Plugins.Flash.build` will return zero.
19 * Browser.Plugins.Flash.version - (*number*) The major version of the flash plugin installed.
20 * Browser.Plugins.Flash.build - (*number*) The build version of the flash plugin installed.
22 Browser.Request {#Browser:Browser-Request}
23 ------------------------------------------
25 * Browser.Request - (*object*) The XMLHTTP object or equivalent.
27 Browser.exec {#Browser:Browser-exec}
28 ------------------------------------
30 Executes the passed in string in the browser context.
32 ### Example:
34         Browser.exec('alert("Moo!");');
37 Deprecated {#Deprecated}
38 ========================
40 ### User Agent detection
42 The functionality described below uses User Agent detection (either the UA string or platform string) to determine the correct values. You are encouraged to use other ways of reaching your goal, like feature detection (`Browser.Features`, your own or [has.js][]), progressive enhancement (the act of having the least compatible features "on top", so the other features still work) and/or graceful degredation (building with all features, but tweaking to have non-compatible things "fall back").
44 #### See also:
46 [MDN about Browser detection using the user agent][]
48 [has.js]: https://github.com/phiggins42/has.js
49 [MDN about Browser detection using theu ser agent]: https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent
51 Browser.name {#Browser:Browser-name}
52 ------------------------------------
54 **Important note:** The use of this feature is deprecated and it will be moved to a compatibility-only version in the future.
56 'Browser.name' reports the name of the Browser as string, identical to the property names of the following Boolean values:
58 * Browser.ie - (*boolean*) True if the current browser is Internet Explorer <= 10.
59 * Browser.modernie - (*boolean*) True if the current browser is Internet Explorer >= 11.
60 * Browser.firefox - (*boolean*) True if the current browser is Firefox.
61 * Browser.safari - (*boolean*) True if the current browser is Safari.
62 * Browser.chrome - (*boolean*) True if the current browser is Chrome.
63 * Browser.opera - (*boolean*) True if the current browser is Opera.
65 In addition to one of the above properties a second property consisting of the name and the major version is provided ('Browser.ie6', 'Browser.chrome15', ...).
67 If 'Browser.chrome' is True, all other possible properties, like 'Browser.firefox', 'Browser.ie', ... , will be `undefined`.
69 ### Example:
71         alert(Browser.name); // Alerts "ie" in Internet Explorer, "firefox" in Mozilla Firefox, "chrome" in Google Chrome, "safari" or "opera".
73         if (Browser.ie){
74                 // This code will only run in IE <= 10
75         }
77         if (Browser.firefox2){
78                 // This code will only run in Firefox 2
79         }
81         if (Browser.ie6 || Browser.ie7){
82                 // Please upgrade your browser
83         }
85 If an IE document is set to backwards compatibility mode using the X-UA-Compatible header, then the Browser object is treated as if the earlier version of the browser is running.
87 ### Browser.ie vs. Browser.modernie:
89 The primary use of `Browser.ie` is activating "legacy code", such "legacy code" is no longer required in more recent versions of Internet Explorer (and may not even work anymore). Having `Browser.ie == true` for modern IE in this deprecated functionality would do more harm than good, even though it's technically correct. Since this functionality is deprecated, this technical incorrectness shouldn't cause any problems. Moreover, `Browser.ie11` will still work and `Browser.name` will still equal "ie".
91 Browser.version {#Browser:Browser-version}
92 ------------------------------------------
94 **Important note:** The use of this feature is deprecated and it will be moved to a compatibility-only version in the future.
96 'Browser.version' reports the version of the Browser as number.
98 ### Example:
100         alert(Browser.version); // Alerts '3.6' in FireFox 3.6.13
102 Browser.Platform {#Browser:Browser-Platform}
103 --------------------------------------------
105 **Important note:** The use of this feature is deprecated and it will be moved to a compatibility-only version in the future.
107 * Browser.Platform.mac - (*boolean*) True if the platform is Mac.
108 * Browser.Platform.win - (*boolean*) True if the platform is Windows.
109 * Browser.Platform.linux - (*boolean*) True if the platform is Linux.
110 * Browser.Platform.ios - (*boolean*) True if the platform is iOS.
111 * Browser.Platform.android - (*boolean*) True if the platform is Android
112 * Browser.Platform.webos - (*boolean*) True if the platform is WebOS
113 * Browser.Platform.other - (*boolean*) True if the platform is neither Mac, Windows, Linux, Android, WebOS nor iOS.
114 * Browser.Platform.name - (*string*) The name of the platform.
116 Browser.Engine {#Browser:Browser-Engine}
117 ----------------------------------------
119 **Important note:** The *Browser.Engine* object is deprecated since MooTools 1.3, and only available in the 1.2-compatibility version.
121 ### Engine:
123 * Browser.Engine.trident - (*boolean*) True if the current browser uses the trident engine (e.g. Internet Explorer).
124 * Browser.Engine.gecko - (*boolean*) True if the current browser uses the gecko engine (e.g. Firefox, or any Mozilla Browser).
125 * Browser.Engine.webkit - (*boolean*) True if the current browser uses the webkit engine (e.g. Safari, Google Chrome, Konqueror).
126 * Browser.Engine.presto - (*boolean*) True if the current browser uses the presto engine (e.g. Opera 9).
127 * Browser.Engine.name - (*string*) The name of the engine.
128 * Browser.Engine.version - (*number*) The version of the engine. (e.g. 950)