Skip to content

Instantly share code, notes, and snippets.

@docluv
Created May 15, 2014 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save docluv/51ad2e57fc8a50997ee1 to your computer and use it in GitHub Desktop.
Save docluv/51ad2e57fc8a50997ee1 to your computer and use it in GitHub Desktop.
Core Site Redirect using feature detection
<script>
var ef = "?_escaped_fragment_=";
if (!('querySelector' in document)
|| !('localStorage' in window)
|| !('addEventListener' in window)
|| !('matchMedia' in window)) {
if (window.location.href.indexOf("#!") > 0) {
window.location.href = window.location.href.replace("#!", ef);
} else {
if (window.location.href.indexOf(ef) < 0) {
window.location.href = window.location.href + ef;
}
}
} else {
if (window.location.href.indexOf(ef) >= 0) {
window.location.href = window.location.href.replace(ef, "#!");
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment