473,545 Members | 1,981 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change page margins

I'm trying to write a javascript function that 'slides' a page a bit down by
retreiving the current top-margin of the body, and then setting it to the
old margin + 50px extra..
The problem here is, I can't seem to retreive the current margin.
Here's what I use now (which returns an empty value):

<html>
<style> body { background-color: yellow; margin-top: 100px; }</style>
<body>
<script language='javas cript'>
document.write( 'current margin: ' + document.body.s tyle.marginTop) ;
</script>
</body>
</html>

Any ideas?
Jul 20 '05 #1
2 8647
Try using document.body.c urrentStyle.mar ginTop:
<html>
<style> body { background-color: yellow; margin-top: 100px; }</style>
<body topmargin="3">
<script language='javas cript'>
alert('current margin: ' + document.body.c urrentStyle.mar ginTop);
</script>
</body>
</html>

--output: current margin: 100px
Mike
"Jourik Feenstra" <jo****@selwerd .nl> wrote in message news:<bu******* ***@info.servic e.rug.nl>...
I'm trying to write a javascript function that 'slides' a page a bit down by
retreiving the current top-margin of the body, and then setting it to the
old margin + 50px extra..
The problem here is, I can't seem to retreive the current margin.
Here's what I use now (which returns an empty value):

<html>
<style> body { background-color: yellow; margin-top: 100px; }</style>
<body>
<script language='javas cript'>
document.write( 'current margin: ' + document.body.s tyle.marginTop) ;
</script>
</body>
</html>

Any ideas?

Jul 20 '05 #2
no************* ****@scovetta.c om (Michael Scovetta) writes:
Try using document.body.c urrentStyle.mar ginTop:


That works in IE only.
The W3C DOM method is
document.defaul tView.getComput edStyle(documen t.body,"").marg inTop
It works in Mozilla and (IIRC) Opera 7.20+.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4838
by: Jody Gelowitz | last post by:
I am having a problem with printing selected pages. Actually, the problem isn't with printing selected pages as it is more to do with having blank pages print for those pages that have not been selected. For example, if I were to have 5 pages with every second page printing, I would get the following results: Page 1 = Print OK Page 2 =...
1
3758
by: Holly | last post by:
Hi, I am using framework 1.0 to implement a printing method. The page margins I set won't show correctly on my print out. The code is: PageSettings pset=new PageSettings(); pset.Margins =new Margins(10,10,100,100); printDoc.DefaultPageSettings=pset; I have seen some explaination about PrintDocument.OriginAtMargins property. But I am not...
2
13620
by: Sean McKaharay | last post by:
I want to find out how I can change the page orientation of a printer.
0
2005
by: brettk | last post by:
Thanks to Bob's help, I was able to get .tif printing working. Now i've got a new problem; if the image is more than one page, it only prints the first page. Here's my code: ############################################ public class PrintTif {
1
1333
by: Keith | last post by:
I'm trying to set an ASP.NET page so that is has no margins. I'm using Flow Layout mode, and I keep setting all the document's margin properties to zero, but when I pull the page up in Internet Explorer, it still appears to have margins. Does anyone have an idea of what I'm doing wrong or what I can do to correct it?
0
2018
by: ghadley_00 | last post by:
Hi, I have a report that has fields that grow/shrink. These reports each have an image as a background. For records that cause the boxes to shrink / grow I get a second page that only has the image background. I don't, however, get the section margins are wider than the report margins.... I'm dealing with 8.5x11 printouts, and the...
7
21712
by: steve | last post by:
Hi All I have created rdlc files and when I load them into Report Viewer at run time they appear OK If I click on 'Print layout' button on Report Viewer the view again appears acceptable If I click on 'Page setup' button the margins left & right are not what I set on the rdlc file at design time (1.5cm) they are 5.9mm
7
20687
by: Mark | last post by:
Hi, I am creating application in VB 2005. and when I print report it adds extra 0.45 cm margin on left and top, and the reason for this is physical margins of printer. Is it possible to change printer's physical margins using VB coding? Cheers -- Osmotion Blue
0
2096
by: jigsmshah | last post by:
I need to print a text file .When i print it ,it is not printed exactly form 0,0 coordiante of the page. I mean the top most left corner.It is leaving some margin from top and from left.The code is an example from MSDN. I am using c# 2.0 and VS 2005.I have just chaged the X coordinate for the DrawString function.i am using it as 0 and the Y...
0
2352
by: thirunavukarasukm | last post by:
Hai.... To print Html page using PrintDialog and Print Document i am created one windows appication.. the windows application have many pages in my booking page i have two buttons one btnprint,btnclose
0
7484
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7415
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7440
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5344
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4963
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1902
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.