Skip to content

Instantly share code, notes, and snippets.

@chiemseesurfer
Last active August 29, 2015 14:15
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 chiemseesurfer/ffeee442b8c770b07efc to your computer and use it in GitHub Desktop.
Save chiemseesurfer/ffeee442b8c770b07efc to your computer and use it in GitHub Desktop.
Switch between screen and mobile view with javascript
<script>
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
var cssUrl = "media/css/handheld.css";
var head = document.getElementsByTagName("head")[0];
var link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = cssUrl;
document.head.appendChild(link);
} else {
var cssUrl = "media/css/style.css";
var head = document.getElementsByTagName("head")[0];
var link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = cssUrl;
document.head.appendChild(link);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment