tailieunhanh - JavaScript Bible, Gold Edition part 83
JavaScript Bible, Gold Edition part 83. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | 668 Part III Document Objects Reference The appName property returns the official name for the browser application. For Netscape browsers the appName value is Netscape for Internet Explorer the value is Microsoft Internet Explorer. The appVersion and userAgent properties provide more meaningful detail. I start with the appVersion property because it is revealing and at times misleading. Using the appVersion property A typical appVersion property value looks like the following one from NN6 one from IE5 Windows en-US compatible MSIE Windows 98 compat DigExt Because most version decisions are based on numeric comparisons for example the version is equal to or greater than 4 you frequently need to extract just the number part of the string returned by the appVersion property. The cleanest way to do this is via the parseInt or parseFloat methods. Use parseInt if you are interested only in the number to the left of the decimal to get the complete leading floating-point number use parseFloat All other characters after the leading numbers are ignored. Also notice that the number does not always accurately represent the version of the browser at hand. For instance reports that it is version . The number is more indicative of a broad generation number rather than a specific browser version number. In other words the browser exhibits characteristics of the first browsers to wear the appVersion of 4 IE it turns out . While this means that can use everything that is in the language and object model of IE4 this obviously doesn t help your script to know if the browser is capable of scripting features. At the same time however buried elsewhere in the appVersion string is the wording MSIE the true version of the browser. IE uses this technique to distinguish the actual version number from the generational number. Therefore for IE you may have to dig deeper by using string methods such as indexOf to
đang nạp các trang xem trước