Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    pa
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Load a different script based on screen resolution

    Ok, I have this area inside a resizable website that I would like to store large rotating images. Everytime a user enters the site, the script will load a different image. That is a script I have, but not one I can change with what I really want to do. Here is what I REALLY want to do.

    If the user is a 1,600 x 1,200 resolution, I would like the script to call up different LARGER images all set to 100% size. If the user is using a 640 x 480 resolution, I would like to load smaller images also with 100% size. The idea is to have the image stretch with the page and still look correct. You can kinda see what I am trying to do here.

    http://www1.hfs.psu.edu/obs/default.shtml

    Let me know what you think

    Thanks in advance!

    Woundworth
    Tall and Proud he stands
    Desert sun his only friend
    The Jumbo Cactuar

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Here's the basics

    <script language="javascript">
    <!--
    function chk_res(){
    w=screen.width

    if(w==1600){
    document.images["img1"].src="pic01.jpg"
    }

    if(w==640){
    document.images["img1"].src="pic02.jpg"
    }

    }
    // -->
    </script>
    </HEAD>

    <BODY onload="chk_res()">

    <img name="img1" src="" style="width:100%;height:200px">


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •