1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

JavaScript change website template if resolution is higher

Discussion in 'Web Development' started by wassup, Jan 23, 2009.

Thread Status:
Not open for further replies.
  1. wassup

    wassup New Member

    Hello,

    Can anyone help with a suggestion or tips about how can i find the user resolution when enter on my website, and if that resolution is higher or lower (eg: or = 1024) then the image from header to change in another one?

    Thanks
     
  2. ishkey

    ishkey Moderator, Logos, Sports Crests Staff Member Verified Member

    Code:
    <script type="text/javascript">
    if ((screen.width<=1024) && (screen.height<=768)) {
    window.location.replace('http://example.com/1024-768-or-less');
    }
    else {
       window.location.replace('http://example.com/greater-than-1024-768');
    }
    </script>
    
    Once you know what a visitor's screen resolution is, you can redirect them to a particular page. Admittedly, you'd be better off with a page that worked at any screen resolution, but anyhow ;)
     
  3. wassup

    wassup New Member

    Thanks ishkey
     
Thread Status:
Not open for further replies.