Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Setting Body CSS with Javascript - please show me how

Reply
Thread Tools

Setting Body CSS with Javascript - please show me how

 
 
jenngra@gmail.com
Guest
Posts: n/a
 
      05-23-2006
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

 
Reply With Quote
 
 
 
 
Nik Coughlin
Guest
Posts: n/a
 
      05-23-2006
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
 
 
 
 
jenngra@gmail.com
Guest
Posts: n/a
 
      05-23-2006

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
 
Nik Coughlin
Guest
Posts: n/a
 
      05-23-2006
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
 
Neredbojias
Guest
Posts: n/a
 
      05-23-2006
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
 
Toby Inkster
Guest
Posts: n/a
 
      05-23-2006
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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
To reduce your body weight & slim your body Loss weight MCSA 0 07-23-2007 07:54 PM
To reduce your body weight & slim your body Loss weight MCSA 0 07-21-2007 05:15 AM
all the text (including tags) between <body> .. </body> tarakparekh@yahoo.com Perl Misc 5 09-07-2005 11:40 PM
Not detecting body.scrollTop and body.scrollLeft in IE6 London Boy Javascript 2 01-12-2004 08:44 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57