+ Reply to Thread
Results 1 to 3 of 3

Thread: Help with this javascript

  1. #1
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Help with this javascript

    I need some javascript code that works in both IE, Firefox. I need it to detect the screen resolution. and if the resolution is greater then 800x600 use the code below

    Code:
    #main {
    	text-align: left;
    	margin: 10px auto;
    	width: 700px;
    	background: #fff;
    	padding: 20px 30px 70px;
    	border-top: 1px solid #E6E6DF;
    	border-right: 1px solid #E6E6DF;
    	border-bottom: 5px solid #E6E6DF;
    	border-left: 1px solid #E6E6DF;
    	}

    I would love to change the world, but they won't give me the source code

  2. #2
    Trixter is offline x10 Lieutenant Trixter is an unknown quantity at this point
    Join Date
    Oct 2006
    Posts
    384

    Re: Help with this javascript

    The command your looking for is screen.width & screen.height.

    Code:
    <SCRIPT language="JavaScript">
    <!--
    if ((screen.width>=800) && (screen.height>=600))
    {
    #main {
    	text-align: left;
    	margin: 10px auto;
    	width: 700px;
    	background: #fff;
    	padding: 20px 30px 70px;
    	border-top: 1px solid #E6E6DF;
    	border-right: 1px solid #E6E6DF;
    	border-bottom: 5px solid #E6E6DF;
    	border-left: 1px solid #E6E6DF;
    	}
    }
    //-->
    </SCRIPT>
    Should Do The Trick
    Last edited by Trixter; 11-09-2006 at 05:15 PM.
    Current:

    Latest:



  3. #3
    Cubeform is offline x10 Lieutenant Cubeform is an unknown quantity at this point
    Join Date
    Aug 2006
    Location
    127.0.0.1
    Posts
    339

    Re: Help with this javascript

    Quote Originally Posted by Trixter
    The command your looking for is screen.width & screen.height.

    Code:
    //There was some code here before, but I removed it from the quote. Check the post above.
    Should Do The Trick
    Won't work. Chris S posted CSS. This will, though:

    HTML Code:
    <script type="text/javascript">
    <!--
    var temp = document.getElementById('main');
    if ((screen.width>=800) && (screen.height>=600))
      {
        temp.style.text-align= "left";
        temp.style.margin="10px auto";
        temp.style.width="700px";
        temp.style.background="#fff";
        temp.style.padding="20px 30px 70px";
        temp.style.border-top="1px solid #E6E6DF";
        temp.style.border-right="1px solid #E6E6DF";
        temp.style.border-bottom="5px solid #E6E6DF";
        temp.style.border-left="1px solid #E6E6DF";
      }
      else 
      {
      //apply your other style
      }
    //-->
    </script>
    Replace "temp" with any variable name you like. Note that I added ".style." and converted the colons into "=". I'm sure there's another way to do it that's easier and better, because I'm not a JavaScript (or HTML DOM) expert.
    Last edited by Cubeform; 11-09-2006 at 06:03 PM.

+ Reply to Thread

Similar Threads

  1. Javascript + CSS Frame = PAIN.
    By DecemberGuild in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 11-07-2006, 02:53 PM
  2. Javascript
    By Tyler in forum Off Topic
    Replies: 1
    Last Post: 10-11-2006, 03:02 AM
  3. Some nice-simple JavaScript effects !!
    By careerbridge in forum Scripts & 3rd Party Apps
    Replies: 1
    Last Post: 07-13-2006, 08:36 AM
  4. Replies: 1
    Last Post: 06-28-2006, 02:52 PM
  5. javascript
    By Brandon in forum Off Topic
    Replies: 6
    Last Post: 01-20-2006, 04:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers