Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Change position of site depending on screen resolution?

  1. #1
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Change position of site depending on screen resolution?

    Havent been here for a long time, might as well give it a shot.

    I need something that "changes" the top: 0px (1024) to top: 50px;(1280) is it possible? might've been a lil unclear..

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    This may work:
    Code:
    <script type="text/javascript">
    window.onload = function() {
      if (window.screen.availWidth > 1024) {
        document.getElementById("myelement").style.top = "50px";
        }
    };
    </script>
    Report back if there's any problems.
    - Mike

  3. #3
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mburt View Post
    This may work:
    Code:
    <script type="text/javascript">
    window.onload = function() {
      if (window.screen.availWidth > 1024) {
        document.getElementById("myelement").style.top = "50px";
        }
    };
    </script>
    Report back if there's any problems.
    u helped me last time i was here too :] ima try it.
    i woulda showed the site if it was up.. ill up it right now so you can see it

    -----------------------------------------------------

    didnt work, put it right under the body tag (was prolly wrong)


    ----------------------------------

    http://920.clan.pro

    i think it woulda be a lot easier with 2 different styles depending on resolution..
    Last edited by NineTwoZero; 05-01-2007 at 07:49 PM. Reason: im not talking english.

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    you didn't follow his code... and I dont think he accounted for someone with a screen with of exactly 1024x800.

    Code:
    <script type="text/javascript">
    // <![CDATA[
    window.onload = function() {
      if (window.screen.availWidth <= 1024) {
        include "<link type='text/css' rel='stylesheet' href='1024.css' media='all' />"
     }
     else {
        include "<link type='text/css' rel='stylesheet' href='1260.css' media='all' />" />
      }
    }
    // ]]>
    </script>
    copy and paste that into your file, and be careful about the punctuation on the includes.... just change the file name for the two css script pages.

    also I suggest getting rid of the frameset it really isn't doing anything with your page.

  5. #5
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by boogyman View Post
    you didn't follow his code... and I dont think he accounted for someone with a screen with of exactly 1024x800.

    Code:
    <script type="text/javascript">
    // <![CDATA[
    window.onload = function() {
      if (window.screen.availWidth <= 1024) {
        include "<link type='text/css' rel='stylesheet' href='1024.css' media='all' />"
     }
     else {
        include "<link type='text/css' rel='stylesheet' href='1260.css' media='all' />" />
      }
    }
    // ]]>
    </script>
    copy and paste that into your file, and be careful about the punctuation on the includes.... just change the file name for the two css script pages.

    also I suggest getting rid of the frameset it really isn't doing anything with your page.
    thanks.. gon try it out directly. frameset aint "mine", its the urls lol. check http://920.ninetwozero.com <-- original, just needed a catchy name for it lol


    -----------------------------------------------------
    didnt work. :/
    Last edited by NineTwoZero; 05-01-2007 at 08:56 PM. Reason: didnt work.. it didnt load the style.. :/

  6. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    The style sheets have to exist, though. Make sure they are valid source (href) names.
    - Mike

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    This should not have been posted in the PHP section. Moving to Javascript now.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    the styles do exist. but it aint loading none when i use the code..

  9. #9
    Join Date
    Jan 2007
    Location
    Sweden
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    alright i created my own script, it doesnt switch though.. only loads the 1024 style. (i put a white background on the 1280 just to make sure that id notice if 1280 was loaded).

    Code:
    var mini = 1024;
    var big = 1280;
    
    if ('document.width == mini') {
    
    document.write('<link rel="stylesheet" type="text/css" href="1024.css" />'); 
    
    }
    else	{
    
    document.write('<link rel="stylesheet" type="text/css" href="1280.css" />');
    }
    im loadin it through <script src="SCRIPTNAME.js" />

    -----------------------------------------------------------------------
    any suggestions? :]

  10. #10
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    document.width isn't a valid property:
    Code:
    var mini = 1024;
    var big = 1280;
    
    if (window.screen.availWidth == mini) {
    
    document.write('<link rel="stylesheet" type="text/css" href="1024.css" />'); 
    
    }
    else	{
    
    document.write('<link rel="stylesheet" type="text/css" href="1280.css" />');
    }
    That should work.
    - Mike

Bookmarks

Posting Permissions

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