Browser exclusion

slaubach8824
Community Member Posts: 5
Hey Folks,
Our employees do have two Options to use our LMS and the WBT of it.
While everything is working fine with Internet Explorer, we do have some trouble with Firefox...
But that doen't matter anyway.
What i Need to know, is how a jascript needs to look like, that would set a variable (e.g. "var_usesIE") to true in case of Using the Internet Explorer. Everything else following is easy for me...
Since I read this thread http://trivantis.com/blog/browser-detection-lectora/
I'd like to ask would this work?:
if( navigator.userAgent.match(/Internet Explorer/i)
{ var_usesIE.set(“true”);
} else {
var_usesIE.set(“false”);
}
It would be grateful if somebody could provide the right script since my Javascript Skill are limited.
Thanx a lot!
Kind regards
Sebastian
Our employees do have two Options to use our LMS and the WBT of it.
While everything is working fine with Internet Explorer, we do have some trouble with Firefox...
But that doen't matter anyway.
What i Need to know, is how a jascript needs to look like, that would set a variable (e.g. "var_usesIE") to true in case of Using the Internet Explorer. Everything else following is easy for me...
Since I read this thread http://trivantis.com/blog/browser-detection-lectora/
I'd like to ask would this work?:
if( navigator.userAgent.match(/Internet Explorer/i)
{ var_usesIE.set(“true”);
} else {
var_usesIE.set(“false”);
}
It would be grateful if somebody could provide the right script since my Javascript Skill are limited.
Thanx a lot!
Kind regards
Sebastian
Comments
-
Here is a script that will detect a Microsoft browser (IE/Edge) and assign "true" to a Lectora variable usesIE. "False" will be assigned for any other browser.
// Get IE or Edge browser version
var version = detectIE();
if (version === false) {
console.log("Not IE/EDGE");
VarusesIE.set("false");
} else if (version >= 12) {
console.log('Edge' + version);
VarusesIE.set("true");
} else {
console.log('IE' + version);
VarusesIE.set("true");
}
// add details to debug result
console.log(window.navigator.userAgent);
/**
* detect IE
* returns version of IE or false, if browser is not Internet Explorer
*/
function detectIE() {
var ua = window.navigator.userAgent;
// Test values; Uncomment to check result …
// IE 10
// ua = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)';
// IE 11
// ua = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
// Edge 12 (Spartan)
// ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0';
// Edge 13
// ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586';
var msie = ua.indexOf('MSIE ');
if (msie > 0) {
// IE 10 or older => return version number
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
}
var trident = ua.indexOf('Trident/');
if (trident > 0) {
// IE 11 => return version number
var rv = ua.indexOf('rv:');
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
}
var edge = ua.indexOf('Edge/');
if (edge > 0) {
// Edge (IE 12+) => return version number
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
}
// other browser
return false;
}
Original script found here.
In the zip file the script is detect.js. -
Categories
- 35.9K All Categories
- 109 ✫ Announcements
- 33.1K Lectora®
- 31.1K Lectora Discussions
- 29K Lectora Desktop
- 2K Lectora Online
- 2K Lectora Feature Requests
- 71 Lectora User Groups
- 36 Lectora Accessibility User Group (LAUG)
- 25 ELB Learning Content
- 25 ELB Learning Content Discussions
- 327 CenarioVR®
- 194 CenarioVR Discussions
- 133 CenarioVR Feature Requests
- 42 Rockstar Learning Platform®
- 39 Rockstar Learning Platform Discussions
- 108 CourseMill®
- 108 CourseMill Discussions
- 47 ReviewLink®
- 47 ReviewLink Discussions
- 7 The Training Arcade®
- 7 The Training Arcade Discussions
- 936 All Things eLearning
- 37 eLearning Development
- 546 Learning Management System (LMS) Integration
- 333 Web Accessibility
- 1.2K ♪ The Green Room
- 9 Additional Learning Products