Tiny Javascript Function to Redirect to Different Pages Given Different Screen Resolution


If you want to improve user experience when browsing your website, given that you know the screen resolution they are on, then the following is a quick Javascript solution that works like a charm.

1
2
3
4
5
6
7
8
<script language='javascript'>
    function redirect() {
        if (screen.width == 1024) location.href = "1024.html";
        else if (screen.width == 800) location.href = "800.html";
        else return(false);
    }
    redirect();
</script>
<script language='javascript'>
	function redirect() {
		if (screen.width == 1024) location.href = "1024.html";
		else if (screen.width == 800) location.href = "800.html";
		else return(false);
	}
	redirect();
</script>

Although, I doubt that how many internet users are still using these ‘low’ screen resolution e.g. 1024 or 800 width.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
125 words
Last Post: Loop Implementation at Windows Batch Programming
Next Post: C/C++ Coding Exercise - Recursive Computation of Value e

The Permanent URL is: Tiny Javascript Function to Redirect to Different Pages Given Different Screen Resolution

Leave a Reply