Home > Web Front-end > JS Tutorial > How to identify your browser's JavaScript engine

How to identify your browser's JavaScript engine

高洛峰
Release: 2016-11-28 13:24:12
Original
1303 people have browsed it

Available for both PC browsers and mobile browsers.

The principle is this js:

window.onload = function() {  
  var v8string = 'function%20javaEnabled%28%29%20%7B%20%5Bnative%20code%5D%20%7D';  
     
  if (window.devicePixelRatio)  //If WebKit browser  
  {  
     if (escape(navigator.javaEnabled.toString()) === v8string)  
     {  
        display('V8 detected');  
     }  
     else 
     {  
        display('JSC detected');  
     }  
  }  
  else {  
    display("Not a WebKit browser");  
  }  
     
  function display(msg) {  
    var p = document.createElement('p');  
    p.innerHTML = msg;  
    document.body.appendChild(p);  
  }  
     
};
Copy after login

First detect the WebKit-specific attribute devicePixelRatio, and then detect the implementation of the v8-specific javaEnabled function.

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template