1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Javascript help

Discussion in 'Web Design & Development' started by Devonance, Sep 23, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. Devonance

    Devonance Thread Starter

    Joined:
    Aug 22, 2008
    Messages:
    12
    I have this code right here:


    <SCRIPT language="JavaScript">
    <!--
    if ((screen.width>=1024) && (screen.height>=768))
    {
    window.location="http://kevin61292.007si...
    }
    if ((screen.width>=1440) && (screen.height>=900))
    {
    window.location="http://kevin61292.007si...
    }
    if ((screen.width>=1360) && (screen.height>=768))
    {
    window.location="http://kevin61292.007si...
    }
    if ((screen.width>=1280) && (screen.height>=800))
    {
    window.location="http://kevin61292.007si...
    }
    if ((screen.width>=1280) && (screen.height>=768))
    {
    window.location="http://kevin61292.007si...
    }
    if ((screen.width>=1280) && (screen.height>=720))
    {
    window.location="http://kevin61292.007si...
    }
    if ((screen.width>=1152) && (screen.height>=864))
    {
    window.location="http://kevin61292.007si...
    }
    if ((screen.width>=800) && (screen.height>=600))
    {
    window.location="http://kevin61292.007si...
    }

    //-->
    </SCRIPT>

    and it works some of them time, what it does is it puts you to a different page according to your resolution on your computer. But, i have a 1440 by 900 resolution, and i put it down to 800 by 600, and it didn't go to the desired webpage for that resolution... did i type it in wrong? or does this code only work for 2 types of resolutions?

    BTW, i meant to put the ... at the end of the site URL's, because i dont want people going there yet, lol.

    thanks in advance!
     
  2. MMJ

    MMJ Guest

    Joined:
    Oct 15, 2006
    Messages:
    3,625
    What does the final url look like?

    Code:
    http://kevin61292.007xxxx.com/*WIDTH*x*HEIGHT*
    ?
     
  3. Devonance

    Devonance Thread Starter

    Joined:
    Aug 22, 2008
    Messages:
    12
    what do you mean? the URL doesnt have the *WIDTH*x*HEIGHT* in it :confused:


    anyway, someone on yahoo answers gave me this:

    Code:
    <script type="text/javascript">
    var w = screen.width;
    var h = screen.height;
    
    // first satisfied if/else-if will abort the remaining test, so 
    // start with the largest width/height combination and 
    // work down to the smallest - note that all after the first 
    // are else-if, and the last is else
    if ((w >= 1440) && (h >= 900)) {
    loc = "http://kevin61292.007sites.com/biblebookcat-Highres1440by900.html
    }
    else if ((w >= 1360) && (h >= 768)) {
    loc = "http://kevin61292.007sites.com/temp1.html
    }
    else if ((w >= 1280) && (h >= 800)) {
    loc = "http://kevin61292.007sites.com/temp2.html
    }
    else if ((w >= 1280) && (h >= 768)) {
    loc = "http://kevin61292.007sites.com/temp3.html
    }
    else if ((w >= 1280) && (h >= 720)) {
    loc = "http://kevin61292.007sites.com/temp4.html
    }
    else if ((w >= 1152) && (h >= 864)) {
    loc = "http://kevin61292.007sites.com/temp5.html
    }
    else if ((w >= 1024) && (h >= 768)) {
    loc = "http://kevin61292.007sites.com/temp6.html
    }
    // default 
    // replaces if ((w >= 800) && (h >= 600)) but actually 
    // means ((w < 1024) && (h < 768)) as written
    else {
    loc = "http://kevin61292.007sites.com/test2.html
    }
    
    window.location = loc;
    </script>
    
    <SCRIPT LANGUAGE="JavaScript"> 
    <!--
    but it still doesnt work... all i want to is if someone comes to my website with 800x600 resolution, they wont have to scroll sideways, and if someone has 1440x900 (like me) they dont see the background image in the top left hand corner. i read online about this and they said to make a separate webpage for different resolutions. it that the only way?

    i dont know php and very little Javascript, so is there a way to make the website look nice in a different resolution in HTML?
     
  4. MMJ

    MMJ Guest

    Joined:
    Oct 15, 2006
    Messages:
    3,625
    Yes, if you do it properly with CSS you can make it so that the layout is fluid.

    I suggest that you make a new thread asking how to create fluid css layout where the background image stays centered.
     
  5. Devonance

    Devonance Thread Starter

    Joined:
    Aug 22, 2008
    Messages:
    12
    Thanks! i will make a new one :D
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/752489

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice