Reputation: 6362
How to detect browser version and display not supported message I would like to support only IE9 and above and Chrome
Upvotes: 0
Views: 3416
Reputation: 11
You can put conditional comments in the HEAD tag to create variables that indicate if you have an IE browser.
<script type="text/javascript">
var supportedBrowser = 1;
</script>
<!--[if lte IE 8]><script>var supportedBrowser=0;</script><![endif]-->
Now if you do not have an IE browser or if you have IE8 or lower, supportedBrowser == 0, so you can use a simple if-statement:
if(supportedBrowser != 1){
// do whatever you want here...
}
Upvotes: 1
Reputation: 145388
I suggest you to check $.support
which stands for:
A collection of properties that represent the presence of different browser features or bugs. Primarily intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally to improve page startup performance.
Previously there was $.browser
property which was useful for checking the browser version. However, nowadays it is deprecated due to inconsistency.
Upvotes: 1