I have a link to a script in the head section of my page in the traditional format, i.e.
<script src="scripts/scriptname.js" type="text/javascript"></script>
I would like to prevent this script loading in IE8 and earlier and also on iPhones/iPads and mobile devices in general.
I have this statement for preventing it running in IE8, but I am not sure how to adapt this to include earlier versions of IE as well, and I am also not sure about mobile devices:
<!--[if !IE 8]><!-->
<script src="scripts/scriptname.js" type="text/javascript"></script>
<!--<![endif]-->
Could someone help with this?
Thanks,
Nick
this will include the block for Internet Explorer 8 and lower ( lt = less than ).
But – if you have to adapt the script just for mobile devices too, i think a javascript solution is the best.
Check the user agent by the navigator object for browser and device, like this:
Include all mobile devices can be too much. Switch by the screen size is a good way:
with browser detection for finding MSIE but not 9.0: