bowser icon indicating copy to clipboard operation
bowser copied to clipboard

How to include this library with a script tag?

Open lukepass opened this issue 5 years ago • 5 comments
trafficstars

Hello and sorry for my lack of knowledge about modern JavaScript. How can I include this library using a <script> tag?

lukepass avatar Mar 23 '20 14:03 lukepass

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

danielebarell avatar Mar 23 '20 18:03 danielebarell

Thanks! That worked perfectly, I used the bundled.js version which I think should contain the polyfill?

lukepass avatar Mar 24 '20 13:03 lukepass

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.

darmbrust avatar Apr 16 '20 21:04 darmbrust

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 image

So what gives?

3SCadmin avatar May 14 '20 01:05 3SCadmin

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

darmbrust avatar May 14 '20 03:05 darmbrust