Skip to content

Instantly share code, notes, and snippets.

@abierbaum
Forked from my8bird/gist:3959405
Created November 6, 2012 15:01
Show Gist options
  • Save abierbaum/4025235 to your computer and use it in GitHub Desktop.
Save abierbaum/4025235 to your computer and use it in GitHub Desktop.
Chrome Frame example
<!DOCTYPE html>
<html>
<head>
<script >
// Check that we have a supported browser
(function() {
var ua = window.navigator.userAgent,
in_chrome = /chrome/i.test(ua),
in_chrome_frame = /chromeframe/i.test(ua), // Notice inChrome is true if inChromeFrame is
in_ie = /msie/i.test(ua),
is_webkit = /webkit/i.test(ua);
console.log('chrome:' + in_chrome + ' chromeframe:' + in_chrome_frame +
' ie:' + in_ie + ' webkit:' + is_webkit);
}());
</script>
</head>
<body>
<div id='in_ie' style="display:none">
<p>To run TACCS Mobile in Internet Explorer, you need to install a plugin.</p>
<p>Please install the <a href="http://www.google.com/chromeframe?quickenable=true">Chrome Frame plugin</a>.</p>
</div>
<div id="unsupported" style="display:none">
<p>Your browser is not supported by TACCS Mobile.</p>
<p>We recommend using <a href="http://www.google.com/chrome">Google Chrome</a> for
maximum security and performance.</p>
</div>
<script>
(function() {
if (in_ie) {
document.getElementById('in_ie').style.display = 'block';
} else {
document.getElementById('unsupported').style.display = 'block';
}
}());
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<script >
// Check that we have a supported browser
(function() {
var ua = window.navigator.userAgent,
in_chrome = /chrome/i.test(ua),
in_chrome_frame = /chromeframe/i.test(ua), // Notice inChrome is true if inChromeFrame is
in_ie = /msie/i.test(ua),
is_webkit = /webkit/i.test(ua);
console.log('chrome:' + in_chrome + ' chromeframe:' + in_chrome_frame +
' ie:' + in_ie + ' webkit:' + is_webkit);
if(!(is_webkit || in_chrome_frame)) {
console.log('redirecting for unsupported browser');
window.location.href = window.location.href.replace('index.html', 'bad_browser.html');
}
}());
</script>
</head>
<body>
Browser is supported.
</body>
</html>
#!/usr/bin/env python
import sys
import SimpleHTTPServer
import SocketServer
PORT = 8000
if len(sys.argv) > 1:
PORT = int(sys.argv[1])
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
@abierbaum
Copy link
Author

@abierbaum
Copy link
Author

redirect: window.location.href = "other place"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment