How to detect visitor’s browser accessing your Shopify store
In some cases, you may need to detect a visitor’s browser to your Shopify store to perform certain actions for each specific browser. You can detect which and what version of browser have used by your website visitors by using simple JavaScript codes.
The below Javascript script to help you do that.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; var isFirefox = typeof InstallTrigger !== 'undefined'; var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification)); var isIE = /*@cc_on!@*/false || !!document.documentMode; var isEdge = !isIE && !!window.StyleMedia; var isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime); var isBlink = (isChrome || isOpera) && !!window.CSS; if (isOpera) { //This is Opera browser } else if (isFirefox) { //This is Firefox browser } else if (isSafari) { //This is Safari browser } else if (isIE) { //This is Internet Explorer browser } else if (isEdge) { //This is Microsoft Edge browser } else if (isChrome) { //This is Chrome browser } else if (isBlink) { //This is Blink browser } |