Skip to main content
Home / Code Snippets / JavaScript / Redirect Mobile Devices

Redirect Mobile Devices

<script type="text/javascript">
if (screen.width <= 699) {
document.location = "mobile.html";

"mobile.html" would be replaced with the location of wherever your mobile version resides. This technique could be adapted to load an alternate stylesheet as well.

For iPhones/iPods Specifically

<script language=javascript>
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
icon-link icon-logo-star icon-search icon-star