Home >Web Front-end >JS Tutorial >How to identify your browser's JavaScript engine
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); } };
First detect the WebKit-specific attribute devicePixelRatio, and then detect the implementation of the v8-specific javaEnabled function.