Determines if the script is being ran in a browser - Node.js Environment

Node.js examples for Environment:Browser

Description

Determines if the script is being ran in a browser

Demo Code

/**/*  w  ww . j a  va2 s . c o m*/
 * Determines if the script is being ran in a browser
 * @returns {boolean}
 */
var isBrowser = function () {
    return (typeof(window) !== 'undefined' && !!document && !!document.getElementsByTagName);
};

Related Tutorials