Skip to content

Instantly share code, notes, and snippets.

@critzjm
Created January 6, 2011 16:21
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save critzjm/768104 to your computer and use it in GitHub Desktop.
Save critzjm/768104 to your computer and use it in GitHub Desktop.
Javascript that will detect a mobile browse and redirect to another page, unless a querystring parameter of full=true exists
Redirecting...
<script language="javascript">
<!--
if(!window.location.search.substring(1) == "full=true") { // do not redirect if querystring is ?full=true
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/Blackberry/i) || navigator.userAgent.match(/WebOs/i)) { // detect mobile browser
window.location.replace("http://url-of-your-mobile-page"); // redirect if mobile browser detected
}
}
-->
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment