PDA

View Full Version : Detect screen resolution and redirect page?



davelf
11-20-2014, 08:05 AM
So i implement this script to detect the screen resolution when the first time user enter to the URL:


<script>
if (window.screen.width <= 400) {
window.location = 'landscape.html'; //for example
}
</script>

In side the landscape.html, message like "please rotate your cellphone to landscape" and then the page will automatically refresh it to the real index page. if the user rotate the cellphone to landscape(or resolution >=400).

But if the user rotate the cellphone to portrait again, the script will redirect the user again to landscape.html.

How to make it work automatically, without the user click manually to refresh page?:confused: