Detecting browser and protocol in Javascript

<script type="text/javascript">
 
    if(/chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) && location.protocol=='http:') {
        alert('Using current position in chrome restricted under http protocol')
    }
    else if (/msie/.test(navigator.userAgent.toLowerCase())) {
        console.log("This browser is MSIE");
    }
    else if (/firefox/.test(navigator.userAgent.toLowerCase())) {
        console.log("This browser is Firefox");
    }
 
</script>

Leave a Reply