bowser
bowser copied to clipboard
How to include this library with a script tag?
Hello and sorry for my lack of knowledge about modern JavaScript.
How can I include this library using a <script> tag?
Hi @lukepass. Following the way it works for me:
in html add:
in JavaScript try: const info = bowser.parse(window.navigator.userAgent) console.log(JSON.stringify(info));
in my local machine it logs: {"browser":{"name":"Firefox","version":"75.0"},"os":{"name":"Windows","version":"NT 10.0","versionName":"10"},"platform":{"type":"desktop"},"engine":{"name":"Gecko","version":"20100101"}}
Hope it helps! dan
Thanks! That worked perfectly, I used the bundled.js version which I think should contain the polyfill?
Something like this should really be on the front page docs... If you don't work with javascript every day, the 10 different ways of having modular javascript doesn't really help someone that just wants to use a simple library to detect the browser type.
Something like this should really be on the front page docs
100% agree. Why are there no installation instructions? Why does it have to be a cryptic puzzle? Even after someone posts the answer, I still can't figure out where he got that information.
Also:
followed the the above instructions, works like a charm.. except when I tried IE11

So what gives?
Yea... I also found out the hard way after figuring out this mess, that the current release is useless in IE 11. Which is kinda the point of the library. Sigh. You need to either go back to an older version, or use the latest, and build it yourself... cause nobody has done a release since this was fixed: https://github.com/lancedikson/bowser/issues/359