Skip to content

Instantly share code, notes, and snippets.

@freshyill
Created September 2, 2011 01:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save freshyill/1187714 to your computer and use it in GitHub Desktop.
Simple IE 6 alert with conditional comments and jQuery
$('document').ready(function(){
// Grab the message from the text file
var ie6message = 'alert.txt';
// Create a div to hold the alert
var alertdiv = $('<div id="alert">');
// Load the message into the div
alertdiv.load(ie6message);
// Insert the message into the page. Notice the .ie6 class, which only appears when using IE 6.
$('.ie6 body').prepend(alertdiv);
});
<h1>Whoa there!</h1>
<p>That's a pretty old browser you got there. You'll have a better experience here if you upgrade to something from the past decade. I recommend <a href="http://google.com/chrome" title="Chrome">Chrome</a> or <a href="http://firefox.com" title="Firefox">Firefox</a>.</p>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<title>Simple IE 6 alert with conditional comments and jQuery</title>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="script.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment