You can check Chrome and a specific version of Chrome as follows:
var have_nacl = false;
var have_pnacl = false;
var index = navigator.userAgent.indexOf('Chrome');
if (index != -1) {
var version = parseFloat(navigator.userAgent.substring(index + 7));
if (31 <= version) have_pnacl = true;
if (14 <= version) have_nacl = true;
}
. 31+ PNaCl . NaCl Chrome, , NaCl. - , NaCl . . :
var watchdog;
var watchdog_time;
function watchdog_timeout() {
alert('NaCl module failed to load');
}
function watchdog_clear() {
clearTimeout(watchdog);
}
function watchdog_set(time) {
watchdog_time = time;
watchdog = setTimeout(watchdog_timeout, time);
}
watchdog_set(5000);
var module = document.getElementById('module');
module.addEventListener('load', function () {
watchdog_clear();
alert('NaCl module loaded');
}, true);
module.innerHTML = '<embed src="module.nmf" type="application/x-nacl"/>';
, HTML - :
<div id="module"></div>
, .
function watchdog_extend() {
watchdog_clear();
watchdog_set(watchdog_time);
}
module.addEventListener('loadstart', watchdog_extend, true);
module.addEventListener('progress', watchdog_extend, true);