Skip to content

Instantly share code, notes, and snippets.

@nicholasdunbar
Last active November 5, 2019 18:53
Show Gist options
  • Save nicholasdunbar/9242264 to your computer and use it in GitHub Desktop.
Save nicholasdunbar/9242264 to your computer and use it in GitHub Desktop.
Detect IE8 or a lesser version of IE in JavaScript.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Detect IE8</title>
<head>
<script type="text/javascript" id="init-ie-var">
var isIE8OrLess = false;
</script>
<!--[if lte IE 8]>
<script type="text/javascript" id="set-ie-var">
isIE8OrLess = true;
</script>
<![endif]-->
</head>
<body>
<script type="text/javascript" id="use-ie-var">
if (isIE8OrLess){
//is IE8 or a lesser version
} else {
//is not IE or a greater version of IE than IE8
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment