Skip to content

Instantly share code, notes, and snippets.

Created January 6, 2011 16:21
  • Star 5 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
What would you like to do?
Javascript that will detect a mobile browse and redirect to another page, unless a querystring parameter of full=true exists
<script language="javascript">
if(! == "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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment