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 5 of 5
  1. #1
    Regular Coder jfreak53's Avatar
    Join Date
    May 2004
    Location
    Guatemala
    Posts
    477
    Thanks
    19
    Thanked 10 Times in 10 Posts

    DIV Widths and DOCTYPE

    So I didn't know whether to put this in HTML & CSS or here. So I'm just going to put it here and the mods can move it if needed.

    So I had this script working for auto width of a DIV, then I added DOCTYPE to the top of my document, now it won't change the width ha ha. I have tried with all DOCTYPE's and same thing.

    The JS I am using is:

    Code:
    window.onload=function(){
    document.getElementById("right").style.width= + screen.width - 193;
    }
    As I said this worked before I added DOCTYPE to the top of the HTML. But when I add any one of the DOCTYPES it stops working.

    Any ideas?
    "FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
    http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
    http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
    http://www.microtronix-tech.com -- Web design and programming

  • #2
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Try this.

    Code:
    window.onload = (function(){
      var right = document.getElementById("right");
      if(right) {
        right.style.width = (screen.width - 193);
      }
    });
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Not sure, but don't you need the units, px, there?
    Last edited by abduraooft; 12-20-2010 at 01:54 PM. Reason: typo
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    jfreak53 (12-20-2010)

  • #4
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Quote Originally Posted by abduraooft View Post
    Not sure, but don;t you need the units, px, there?
    In css you can just write the number without the units which I don't personally do although it can be done, now with javascript im not 100% sure about needing the units but im guessing as it's using styling commands that it would be the same as the css parser.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • #5
    Regular Coder jfreak53's Avatar
    Join Date
    May 2004
    Location
    Guatemala
    Posts
    477
    Thanks
    19
    Thanked 10 Times in 10 Posts
    Hey, we're good now. It was the pixels, didn't even think about it since it was working before that. But I guess it makes sense since I was assigning a DOCTYPE to it, the CSS had to be prefect.

    More of a CSS thing than a javascript thing, Thanks guys.
    "FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
    http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
    http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
    http://www.microtronix-tech.com -- Web design and programming


  •  

    Posting Permissions

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