jquery Gets the name and version information of the browser

Source: Internet
Author: User
Tags format object empty version
In jquery, the $.browser object allows you to get the name and version information of the browser, such as $.browser.chrome true, which means that the current Chrome browser, $. Browser.mozilla is true to indicate that it is currently a Firefox browser and can be $.browser.version to obtain browser version information.

  1. <div id= "Divtest" >
  2. <div class= "title" >
  3. <span class= "FL" > Get browser Name and version number </span>
  4. </div>
  5. <div class= "Content" ></div>
  6. </div>
  7. <script type= "Text/javascript" >
  8. $ (function () {
  9. var strtmp = "Your browser name is:";
  10. if ($.browser.chrome) {//Google browser
  11. Strtmp + + "Chrome";
  12. }
  13. if ($.browser.mozilla) {//Firefox related browser
  14. Strtmp + + "Mozilla FireFox";
  15. }
  16. Strtmp + = "<br/><br/> Version number is:"//Get version number
  17. +?;
  18. $ (". Content"). html (strtmp);
  19. });
  20. </script>


Detects if an object is empty

In jquery, you can invoke a tool function named $.isemptyobject to detect whether the contents of an object is empty, and if it is null, the function returns True, otherwise, the value of false is returned, and the calling format is as follows:

$.isemptyobject (obj);

Where the parameter obj represents the name of the object to be instrumented.

  1. <div id= "Divtest" >
  2. <div class= "title" >
  3. <span class= "FL" > Detect if the object is empty </span>
  4. </div>
  5. <div class= "Content" ></div>
  6. </div>
  7. <script type= "Text/javascript" >
  8. $ (function () {
  9. var obj = {"Name": "Tyrants"};
  10. var strtmp = "You defined one:";
  11. if ($.isemptyobject (obj)) {//Detect is empty
  12. Strtmp + = "Empty Object";
  13. }
  14. else {
  15. Strtmp + = "Non-empty object";
  16. }
  17. $ (". Content"). html (strtmp);
  18. });
  19. </script>

Detects if an object is a raw object

Invokes a tool function named $.isplainobject that detects whether the object is the original object created by the {} or the new object () keyword and, if so, returns True, otherwise, returns a value of FALSE, calling the format:

$.isplainobject (obj);

Where the parameter obj represents the name of the object to be instrumented.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.