Browser detection

ssneg
ssneg Community Member Posts: 1,466 ☆ Roadie ☆
You might have noticed that there is a default Lectora variable called “Browser”. It contains the value of navigator.appName property, which should theoretically contain the name of the browser. Unfortunately, most browsers including IE11, Chrome and Safari return just “Netscape” as their name even on mobile devices, so this is not really useful for anything.



The Browser variable should contain the value of navigation.userAgent, which is unique for each browser version and makes it possible to then build conditional actions, e.g. IF Browser contains "ipad" show Button1 ELSE show Button2.



Click this link to see the appName and userAgent in your browser: http://jsfiddle.net/zj02fubL/

Comments

  • martink
    martink Community Member Posts: 16
    Thanks for the good example - that would be indeed a very good improvement. I have accessed this variable in the past because I was curious but since it only returned Netscape it was not very valuable.



    Best regards,

    Martin