![]() |
|
|
|||||||
![]() |
HTML - Setting Body CSS with Javascript - please show me how |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
|
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
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. |
|
|
|
#5 |
|
Posts: n/a
|
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. |
|
|
|
#6 |
|
Posts: n/a
|
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 |
|