Use JS to identify whether 360 browsers

Source: Internet
Author: User

360 browser to tell the truth is more evil, before the kernel can be returned by the string to determine whether to include the word "360" method to determine

As the following code

Window.navigator.userAgent.indexOf (' 360 ')!=-1

However, after 360 browser updates, the kernel displays the same string as the IE browser, which makes it impossible to determine whether IE or 360. But someone said, since is the same as the kernel of IE, do not need to determine whether it is 360 alone, I said these people stand talking not waist pain, do not know if they have written some code, found in IE and 360 browser performance behavior is not the same. Therefore, this judgment is still necessary, after everyone out of some of the way, such as writing JS to load this image ' res://360se.exe/2/2025 ', I do not know if loading this picture, is not always hanging there, I am too lazy to try this method.

Below I looked at the members of the Window.navigator collection, think of should be so many members of the collection, 360 will not be implemented? Finally, the results finally found some differences, the following gives my judgment code.

 
  1. <%@ page language="java" import="java.util.*" pageencoding= "GBK"%>
  2. <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
  3. <html>
  4. <head>
  5. <base >
  6. <title></title>
  7. <script>
  8. function bro () {
  9. var is360 = false;
  10. var isie = false;
  11. if (Window.navigator.appName.indexOf ("Microsoft")! =-1) {
  12. isie= true;
  13. }
  14. if (isie&& (window.navigator.userprofile+ ') = = = ' null ') {
  15. is360 = true;
  16. }
  17. if (is360) {
  18. document.body.innerText = ' 360 browser ';
  19. }else if (Isie) {
  20. document.body.innerText = ' IE browser ';
  21. }
  22. }
  23. </Script>
  24. </head>
  25. <body onload="bro ();" >
  26. </Body>
  27. </html>


Be careful not to forget this sentence, or your execution will not be right.

 
    1. <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

The above method I have used in the project, the effect is OK.


PS: The above is written a long time ago, now it is useless, now 360 browser 6.3 version, is the same as the Chrome browser kernel, not and the previous IE kernel, 360 really changed to change, the following is now modified code (written on May 30, 2014)

  1. <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
  2. <html>
  3. <head>
  4. <base >
  5. <title></title>
  6. <script>
  7. function bro () {
  8. var is360 = false;
  9. var isie = false;
  10. var isfirefox = false;
  11. var iscrome = false;
  12. var broname = ';
  13. if (window.navigator.userAgent.indexOf (' MSIE ')!=-1&&window.navigator.appname.indexof ("Microsoft")! =-1) {
  14. Isie = true;
  15. broname = ' IE ';
  16. }
  17. if (window.navigator.userAgent.indexOf (' Firefox ')!=-1) {
  18. Isfirefox = true;
  19. broname = ' Firefox ';
  20. }
  21. if (window.navigator.userAgent.indexOf (' Chrome ')!=-1) {
  22. if (window.navigator.webkitPersistentStorage) {
  23. iscrome = true;
  24. broname = ' Chrome ';
  25. }else{
  26. is360 = true;
  27. broname = ' 360 ';
  28. }
  29. }
  30. document.getElementById (' Brotype '). value=Broname;
  31. }
  32. </Script>
  33. </head>
  34. <body onload="bro ();" >
  35. <input type="text" id="Brotype" name="Brotype">
  36. </Body>
  37. </html>


Now please use the latest method to determine.

Use JS to identify whether 360 browsers

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.