Setting Body CSS with Javascript - please show me how

Discussion in 'HTML' started by jenngra@gmail.com, May 23, 2006.

  1. Guest

    Hi & Good evening - can someone please show me how to do this:

    <body id=page_one style=margin:100>

    PAGE CONTENT

    </body>




    <script> ..... I want to reset the <body> margin from 100 to 50 ....

    How can this be done?

    Best regards, Jennifer
     
    , May 23, 2006
    #1
    1. Advertising

  2. Nik Coughlin Guest

    wrote:
    > Hi & Good evening - can someone please show me how to do this:
    >
    > <body id=page_one style=margin:100>
    > </body>
    > <script> ..... I want to reset the <body> margin from 100 to 50 ....


    document.getElementById( "page_one" ).style.margin = "50px";
     
    Nik Coughlin, May 23, 2006
    #2
    1. Advertising

  3. Guest

    Nik Coughlin wrote:
    > wrote:
    > > Hi & Good evening - can someone please show me how to do this:
    > >
    > > <body id=page_one style=margin:100>
    > > </body>
    > > <script> ..... I want to reset the <body> margin from 100 to 50 ....

    >
    > document.getElementById( "page_one" ).style.margin = "50px";


    May I ask one more question? In a scenerio like this:

    <body id=page_one style=margin:100><object id=object_one
    name=object_one data="test.htm" width="500"
    height="500"></object></body>

    How do I set the body margin from test.htm to 50? I thought your step
    would work, but I am unsure how to call this. Thank you so much, Jenn
     
    , May 23, 2006
    #3
  4. Nik Coughlin Guest

    wrote:
    > Nik Coughlin wrote:
    >> wrote:
    >>> Hi & Good evening - can someone please show me how to do this:
    >>>
    >>> <body id=page_one style=margin:100>
    >>> </body>
    >>> <script> ..... I want to reset the <body> margin from 100 to 50
    >>> ....

    >>
    >> document.getElementById( "page_one" ).style.margin = "50px";

    >
    > May I ask one more question? In a scenerio like this:
    >
    > <body id=page_one style=margin:100><object id=object_one
    > name=object_one data="test.htm" width="500"
    > height="500"></object></body>
    >
    > How do I set the body margin from test.htm to 50? I thought your step
    > would work, but I am unsure how to call this. Thank you so much, Jenn


    I don't know because I would never do it that way. Using the object element
    to include one file in another doesn't work very well across browsers. Read
    this for better ways to do the same thing, which should make your little
    problem go away:
    http://allmyfaqs.net/faq.pl?Include_one_file_in_another

    Also there is a bit on that page about the issues with using object.
     
    Nik Coughlin, May 23, 2006
    #4
  5. Neredbojias Guest

    To further the education of mankind, vouchsafed:

    > Hi & Good evening - can someone please show me how to do this:
    >
    > <body id=page_one style=margin:100>
    >
    > PAGE CONTENT
    >
    > </body>
    >
    >
    >
    >
    > <script> ..... I want to reset the <body> margin from 100 to 50 ....
    >
    > How can this be done?



    You don't need to id the body element (-and probably shouldn't):

    document.body.style.margin="50px";

    Also, with css styles, units must be included:

    <body style="margin:100px;">

    --
    Neredbojias
    Infinity has its limits.
     
    Neredbojias, May 23, 2006
    #5
  6. Toby Inkster Guest

    jenngra wrote:

    > <body id=page_one style=margin:100>


    In CSS you *must* specify units (except for '0', because 0px is the same as
    0mm which is the same as 0%). That is, use '100px', not just '100'.

    (The only property where units are optional is 'line-height'.)

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, May 23, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noozer
    Replies:
    1
    Views:
    5,492
    Roy Schestowitz
    Mar 22, 2006
  2. KK
    Replies:
    2
    Views:
    577
    Big Brian
    Oct 14, 2003
  3. London Boy
    Replies:
    2
    Views:
    333
    Keith Bowes
    Jan 12, 2004
  4. nick
    Replies:
    3
    Views:
    385
    Grant Wagner
    Jun 15, 2004
  5. Replies:
    5
    Views:
    210
    A. Sinan Unur
    Sep 8, 2005
Loading...

Share This Page