function performBrowserCheck() { var browserErrorMessage = checkBrowserSupport(); var browserSupported =(browserErrorMessage == null)?true:false; //Check if browser is supported if( ( ! browserSupported ) && (! false) ) { var redirect = getContextPath()+ '/public/policy/BrowserRequirements.jsp'; if( browserErrorMessage != null ) { //Always set a default message if not supported browserErrorMessage = (browserErrorMessage!=null)?browserErrorMessage: 'Browser configuration is not supported'; redirect = redirect+'?message='+escape(browserErrorMessage); } window.location = redirect; } } /*********************************************************************** * This will return an error messages, or null if no error. * @return An error message, or null if none. ***********************************************************************/ function checkBrowserSupport() { var result = 'The browser configuration is not supported'; // Check if the browser version is supported if ( checkForSupportedBrowserVersion() ) { // Check if session cookies can be set if (!checkSessionCookie()) { result = 'Session cookies are not currently enabled'; } else { // Check if persistent cookies can be set. if (!checkPersistentCookie()) { result = 'Persistent cookies are not currently enabled'; } else { // The Browser passed all checks result = null; } } } else { // OS, Browser and/or Browser Version are not supported // window.location = "BrowserNotSupported.html"; } return result; } /*********************************************************************** * Checks if supported browser version * Must be IE 5.0+, Firefox 1.0+, Netscape 7.0+ * @return True if supported, else false. ***********************************************************************/ function checkForSupportedBrowserVersion() { var validBrowser = false; //fail-safe //Check if Netscape 7.1 or greater if (navigator.appName=="Netscape" ) { if(parseFloat(navigator.appVersion)>= 7.1 ) { validBrowser = true; } /********************************************************************* Added for Project 0003 for new Netscape browsers appVersion: 5.0 (Windows; en-US) userAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20050603 Netscape/8.0.2 ********************************************************************/ var getNSVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Netscape")).split("/")[1] if( parseFloat(getNSVersion)>= 8 ) { validBrowser = true; //document.write("Browser is: " + navigator.appName + ". Version: " + getNSVersion ); } } //Check if Firefox 1.0 or greater if(navigator.userAgent.indexOf("Firefox")!=-1){ var versionindex=navigator.userAgent.indexOf("Firefox")+8 if (parseInt(navigator.userAgent.charAt(versionindex)) >= 1) { validBrowser = true; } } //Check if IE 5.0 or greater if (navigator.appVersion.indexOf("MSIE")!=-1) { temp=navigator.appVersion.split("MSIE"); version=parseFloat(temp[1]); if (version>=5) { validBrowser = true; } } /******************************************************************* Check if IE 11.0 or later Code modified at 2013-11-19 by Wei *******************************************************************/ var isAtLeastIE11 = !!(navigator.userAgent.match(/Trident/) && !navigator.userAgent.match(/MSIE/)); if (isAtLeastIE11) { validBrowser = true; } /******************************************************************* Check if chrome and version greater than 3.0. Code modified at 2009-12-18 For Project: F102: IE8 and other browser compatibilities, Safari, Firefox, Chrome *******************************************************************/ if (navigator.userAgent.indexOf("Chrome") != -1 ) { var getCHVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Chrome")).split("/")[1] if( parseFloat(getCHVersion) >= 3) { validBrowser = true; } } /******************************************************************* Check if Safari and version greater than 4.0. Code modified at 2009-12-18 For Project: F102: IE8 and other browser compatibilities, Safari, Firefox, Chrome *******************************************************************/ if (navigator.userAgent.indexOf("Safari") != -1 ) { var getSFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Version")).split("/")[1] if( parseFloat(getSFVersion) >= 4 ) { validBrowser = true; } } /******************************************************************* Check if Opera and version greater than 3.0. Code modified at 2009-12-18 For Opera browser *******************************************************************/ /****** if (navigator.userAgent.indexOf("Opera") != -1 ) { var getOPVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Version")).split("/")[1] if( parseFloat(getOPVersion) >= 10 ) { validBrowser = true; } } *******/ return validBrowser; } /*********************************************************************** * This function is used from the functions checkSessionCookie() and * checkPersistentCookie() to read the value out of the cookie */ function getValueFromCookie(cookieName) { //------------------------------------------------------------------ // Define the cookie name to look for var cookieIndexName = cookieName + '="'; //------------------------------------------------------------------ // Check if any cookie exists in this document. if (document.cookie.length > 0) { // A cookie is available in this document. //-------------------------------------------------------------- // Look for the position of the cookie var cookieStartIndex = document.cookie.indexOf(cookieIndexName); //-------------------------------------------------------------- // Check if the appropriate cookie was found if (cookieStartIndex != -1) { // the CurrentUserCookie was found in the cookies of this // document //---------------------------------------------------------- // Look for the start and the end of the cookie cookieStartIndex += cookieIndexName.length; var cookieEndIndex = document.cookie.indexOf('";', cookieStartIndex); if (cookieEndIndex == -1) { // the end of the cookie list is reached cookieEndIndex = document.cookie.length-'"'.length; } //---------------------------------------------------------- // Return the value that was stored in the cookie return unescape(document.cookie.substring(cookieStartIndex, cookieEndIndex)); } } //------------------------------------------------------------------ // Return an empty string if nothing has been returned yet. return ""; } /*********************************************************************** * This function checks if session cookies can be set. */ function checkSessionCookie() { //------------------------------------------------------------------ // Set the needed variables var cookieName = "TruePassSessionTestCookie"; var cookieValue = 'TruePassTestCookieDummyValue'; var timeBeforeSettingCookie = new Date(); //------------------------------------------------------------------ // Set the cookie document.cookie = cookieName + '="' + cookieValue + '";'; //------------------------------------------------------------------ // Calculate how much time was needed to set the cookie var timeDifference = (new Date()).getTime() - timeBeforeSettingCookie.getTime(); //------------------------------------------------------------------ // Check if setting the cookie lasted to long in Netscape. If // setting the cookie took longer than a few hundred miliseconds // it indicates, that the user had enabled the cookie warnings and // it took him some time to click on a button of the cookie warning. // Netscape does not work properly if cookie warnings are shown. // This is only a problem in Netscape and it does not occur in IE. if (navigator.appName.substring(0,9) != "Microsoft" && timeDifference > 200) { return false; } else { //-------------------------------------------------------------- // Check if the cookie was set correctly. if (getValueFromCookie(cookieName) != cookieValue) { // reset the cookie document.cookie = cookieName + '=""' + '; expires=' + (new Date()).toGMTString(); // The session cookie was not set properly return false; } else { // reset the cookie document.cookie = cookieName + '=""' + '; expires=' + (new Date()).toGMTString(); // The cookie test succeeded return true; } } } /*********************************************************************** * This function checks if persistent cookies can be set */ function checkPersistentCookie() { //------------------------------------------------------------------ // Set the needed variables var cookieName = "TruePassPersistentTestCookie"; var cookieValue = 'TruePassTestCookieDummyValue'; var timeBeforeSettingCookie = new Date(); //------------------------------------------------------------------ // Set the cookie document.cookie = cookieName + '="' + cookieValue + '";' + '; expires=' + (new Date(timeBeforeSettingCookie.getTime() + 1000000)).toGMTString(); //------------------------------------------------------------------ // Calculate how much time was needed to set the cookie var timeDifference = (new Date()).getTime() - timeBeforeSettingCookie.getTime(); //------------------------------------------------------------------ // Check if setting the cookie lasted to long in Netscape. If // setting the cookie took longer than a few hundred miliseconds // it indicates, that the user had enabled the cookie warnings and // it took him some time to click on a button of the cookie warning. // Netscape does not work properly if cookie warnings are shown. // This is only a problem in Netscape and it does not occur in IE. if (navigator.appName.substring(0,9) != "Microsoft" && timeDifference > 200) { return false; } else { //-------------------------------------------------------------- // Check if setting the cookie was set correctly. if (getValueFromCookie(cookieName) != cookieValue) { // reset the cookie document.cookie = cookieName + '=""' + '; expires=' + (new Date()).toGMTString(); // The persistent cookie was not set properly return false; } else { // reset the cookie document.cookie = cookieName + '=""' + '; expires=' + (new Date()).toGMTString(); // The cookie test succeeded return true; } } }