How to forward people with low screen resolution to another address?

Technical

Forward users with screen resolution to another addressRecently I had the following question that I asked myself: How can I forward people to another site if they have a low screen resolution? After looking around I found the answer and in this article I will share it with you!

Before sharing the answer I will share why I had this question. Today more and more people surf the Internet using smartphones and tablets. Most smartphones use a low screen resolution making websites very hard to read and even harder to navigate. Most tablets use a higher screen resolution and therefore the problem is first of all valid for smartphone users. More and more people understand the importance of create mobile friendly sites, and therefore they either try to make a mobile friendly version of their website inside of their already existing website, while others create a different website for mobile users at another address. I wanted to try the latter version and therefore I thought the screen resolution solution was very good.

Therefore, if you want to forward visitors with a certain screen resolution (or lower) you can use the following script. In the script the width is the important number. If you use the following example all users with a screen width smaller than 800pixels and height smaller than 600 pixels will be forwarded to the address written in window location.

<script type=»text/javascript»>
if ( (screen.width < 800) && (screen.height < 600) ) {
    window.location = ‘http://m.example.com’;
    }
</script>

In case you do not want the screen height in the script and only let the screen width decide whether the user should be forwarded or not, change that line to look like this:
if (screen.width<800) {

This is a very basic script which should do the main job for you. Make sure to place it within the header of the webpage (inside the <head> tags). I wish you good luck and hope you will succeed in the project you are currently working at. I will get back with more information on how to make a website for smartphones and tablets later in another article!

No responses yet

    Leave a Reply