WordPress Tricks

Javascript Code to redirect mobile site depending on screen width: For WordPress or HTML sites

Here is a short piece of code which can help you to redirect your html, wordpress or other site to redirect to additional mobile site while visiting your site from smaller screen (like mobile, tablet,tab etc)

*** if you want to use this code, change the “screen.width” and “YOUR MOBILE SITE URL” value as per your requirement.

<script type="text/javascript">
if(window.location.hash != '#mobile=off') {
if (screen.width <= 1023) {
document.location =

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s