Hello Community
I am building a web-page (.NET Core Razorpage) that needs to scan barcodes.
When running it on a zebra device, I can embed the file ebapi-modules.js via
and all works well.
But I need the option to run the page on a mobile and use the camera to scan, or let the user use the UI to enter the options vie Buttons ect.
But when I run the page on a non-enterprise-browser, the embedding of the ebapi-modules.js- file produces a JS-Error, resulting from a function iside this file.
So I need to make sure that this file is only embedded, when running in enterprise browser. Reading the user-agent from the header gives me no solution, because I get nothing to identify the enterprise browser there.
So has anyone already solved this problem and can hive me some solution?
I attached the data I get from the navigator variable in a jpg.
Thank you for your help.
Greetings, Hagen
3 Replies
Hi,
I'm not sure on how to identify the browser reliably via JavaScript, though the accepted solution here may help narrow it down via duck-typing.
As a work-around, perhaps you could either check for errors after embedding the .js file & reload the page without it if there is any issues? Or if the user wants to use a built-in scanner, you could add an additional button that would re-load the page with the required .js files?
Hi James
Thank you very much for your comment.
I actually have tried to react on the exception as an alternative solution.
Because the function is called within the included file, I put a try - catch around the whole compressed code inside the file and this supressed the error.
I think this is really the best solution, as trying to identify the used browser in this case is rather too error-prone.
Sounds like a reasonable work-around, thanks for updating the thread :)