Mastering Bootstrap 4 by Benjamin Jakobus

Mastering Bootstrap 4 by Benjamin Jakobus

Author:Benjamin Jakobus
Language: eng
Format: epub
Publisher: Packt Publishing


To add the logic that makes the alert visible, let us start with a general condition of whether or not the user is using Internet Explorer. We will move to a more specific condition later (whether the user is using a specific version of Internet Explorer). In other words, let us begin by making the browser alert visible only if the visitor's browser is identifying itself as Internet Explorer. The code for this is fairly straightforward. We simply check the $.browser.msie variable. If this variable evaluates to true, then we use jQuery to make our alert visible:

if ($.browser.msie) { $('#unsupported-browser-alert').show(); }

Now let us make our browser test more specific. We now want to test whether the visitor is using both Internet Explorer and whether the version of Internet Explorer (let's say version 8 and below) is unsupported by MyPhoto. To do so, we simply perform a second check using the $.browser.version variable. If the conditional evaluates to true, then the show() function is executed. The show() function modifies the display rule of an element to make it visible:

if ($.browser.msie && $.browser.version <= 8) { $('#unsupported-browser-alert').show(); }

Go ahead and insert this snippet into the head of our HTML document:

<script type="text/javascript"> $( document ).ready(function() { $("nav ul li a").on('click', function(evt) { evt.preventDefault(); var offset = $(this.hash).offset(); if (offset) { $('body').animate({ scrollTop: offset.top }); } }); if ($.browser.msie && $.browser.version <= 7) { $('#unsupported-browser-alert').show(); } }); </script>



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.