Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

HTML - Setting Body CSS with Javascript - please show me how

 
Thread Tools Search this Thread
Old 05-23-2006, 03:52 AM   #1
Default Setting Body CSS with Javascript - please show me how


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



jenngra@gmail.com
  Reply With Quote
Old 05-23-2006, 04:59 AM   #2
Nik Coughlin
 
Posts: n/a
Default Re: Setting Body CSS with Javascript - please show me how

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";


  Reply With Quote
Old 05-23-2006, 05:26 AM   #3
jenngra@gmail.com
 
Posts: n/a
Default Re: Setting Body CSS with Javascript - please show me how


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

  Reply With Quote
Old 05-23-2006, 05:35 AM   #4
Nik Coughlin
 
Posts: n/a
Default Re: Setting Body CSS with Javascript - please show me how

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.


  Reply With Quote
Old 05-23-2006, 07:03 AM   #5
Neredbojias
 
Posts: n/a
Default Re: Setting Body CSS with Javascript - please show me how

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.
  Reply With Quote
Old 05-23-2006, 07:30 AM   #6
Toby Inkster
 
Posts: n/a
Default Re: Setting Body CSS with Javascript - please show me how

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

  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump