Browser exclusion

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

undefined

Discussion (4)

Hey Darrel,

Thank you very much, that was exactly what I was looking for!

Great. I'm glad it helped.

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 =undefined

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.

There is also just the reserved Lectora 'BrowserType' variable that will give you the name of the browser being used. This might be sufficient for your needs instead of using a script.

Discussions have been disabled for this post