diff --git a/src/js/i18n.js b/src/js/i18n.js index 8201000..99dccef 100644 --- a/src/js/i18n.js +++ b/src/js/i18n.js @@ -144,7 +144,9 @@ var _defs = { var _defaultLang = 'en'; var _lang; -var userLang = navigator.language || navigator.userLanguage; +var userLang = typeof navigator !== 'undefined' + ? navigator.language || navigator.userLanguage + : undefined; _lang = _locales.find(function (l) { return l === userLang; }); diff --git a/src/js/util.js b/src/js/util.js index f3d3167..eb98c36 100644 --- a/src/js/util.js +++ b/src/js/util.js @@ -588,8 +588,7 @@ exports.getInnerText = function getInnerText(element, buffer) { exports.getInternetExplorerVersion = function getInternetExplorerVersion() { if (_ieVersion == -1) { var rv = -1; // Return value assumes failure. - if (navigator.appName == 'Microsoft Internet Explorer') - { + if (typeof navigator !== 'undefined' && navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) != null) { @@ -608,7 +607,7 @@ exports.getInternetExplorerVersion = function getInternetExplorerVersion() { * @returns {boolean} isFirefox */ exports.isFirefox = function isFirefox () { - return (navigator.userAgent.indexOf("Firefox") != -1); + return (typeof navigator !== 'undefined' && navigator.userAgent.indexOf("Firefox") !== -1); }; /**