Browser JavaScript engine recognition method

  • 2020-03-26 21:27:36
  • OfStack

The answer is from StackOverflow. Just go to http://jsbin.com/opuvas, which was written by the answerer himself.

The qr code is this website. There are statistics page views, the author wants to know how many people useful, suggest respect the original, do not copy this page.
< img SRC = "border = 0 / / files.jb51.net/file_images/article/201310/20131020170537.png? 2013920101729 ">  

Available for both PC 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); 
} 

}; 

First check the WebKit specific property devicePixelRatio, and then check the v8-specific implementation of the javaEnabled function.

Related articles: