Hello everyone. I am using this script for detecting OS and browsers that was created in a prior post:
var sUsrAg
var nIdx
getBrowserId = function() {
var browsers = [“MSIE”, “Firefox”, “Safari”, “Chrome”, “Opera”];
sUsrAg = window.navigator.userAgent,
nIdx = browsers.length - 1;
for (nIdx; nIdx > -1 && sUsrAg.indexOf(browsers [nIdx]) === -1; nIdx–);
return browsers[nIdx];
}
psychoJS.experiment.addData(“OS”, window.navigator.platform)
psychoJS.experiment.addData(“Browser”, getBrowserId())
This script works when run in Chrome, but when I use it in Microsoft edge or Firefox, I get get errors during the initialization of the experiment. Firefox says: Uncaught ReferenceError: assignment to undeclared variable getBrowserId and Edge says the ‘viewport’ meta element ‘content’ attribute value should not contain ‘user-scalable’.
I am hoping someone with a better knowledge of psychojs could help me figure out how to adjust this code to detect a wider variety of browsers.