npm i @dvhb/badbrowser
http://dvhb.github.io/badbrowser/
Put html for your custom alert windows in /alerts/ with this pattern:
alerts/
ru.html
en.html
...
importbadbrowserfrom'@dvhb/badbrowser'Desktop
- Microsoft Edge, 12+;
- Mozilla Firefox, 37+;
- Google Chrome, 41+;
- Opera, 28+;
- Apple Safari, 8+;
- Yandex Browser, 15+.
Mobile
- Mobile Safari, 7+
- Android Browser, 4+
- Chrome Mobile, 41+;
- Internet Explorer Mobile, 11+;
newbadbrowser({// Min version of browser that will be supportedsupported: {msedge: '12',firefox: '37',chrome: '41',opera: '28',safari: '8',yandexbrowser: '15',safari_mobile: '7',android: '4',chrome_mobile: '41',msie_mobile: '11'},// path to your html alerts// could be a function:// function (ua) {// return '/alerts/' + lang + '.html'// }path: '/alerts/en.html',// if `false` then user's choice will be saved in the cookies// and alert window will not be showen next timeignoreChoice: false})Instead of specifying supported property you can specify unsupported browsers:
newbadbrowser({unsupported: {// the same as supported.chrome = '40'chrome: '39',// the same as supported.firefox = '34'firefox: '33',// will show alert for any mobile browsermobile: true}})Also you can get the flag that indicates compatibility of a current browser
letbb=newbadbrowser({unsupported: {// the same as supported.chrome = '40'chrome: '39',// the same as supported.firefox = '34'firefox: '33',// will show alert for any mobile browsermobile: true}})letisSupported=bb.check();You can manually control warning window:
Shows warning if it is not added yet and removes warning if it exists.
bb.toggleWarning();chromefirefoxmsiemsedgesafariyandexbrowserandroidiosoperasamsungBrowserphantomblackberrywebossilkbadatizenseamonkeysailfishucbrowserqupzillavivaldisleipnirkMeleon