Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print div tag section 1

Status
Not open for further replies.

laker67

Programmer
Jan 18, 2004
31
0
0
US
Hi,I have a div tag as follows.

<DIV STYLE="Left:0px;Top: 110px;Position: absolute;Width: 830;HEIGHT: 500px;overflow: auto">

All the contents of the page are inside this div tag. when when i try to use window.print() ; javascript function only the content on the screen or being printed and not the contents in the page that can be seen once the scrollbar is moved down .Is there a way to print all the contents of the page .
Thanks!!!!
 
this looks like a CSS issue. i don't think you can do anything in javascript to get it to work the way you want.

you can get things to work by putting your style info into a CSS file and link the file to this page. then, create a 2nd CSS file that excludes the height setting (effectively removing the scroll bar) and link this in using the "media" setting of "print".

here's a simple example of what i'm taling about.

Code:
<html>
<head>
<title>CSS Print Test</title>
<link rel="stylesheet"
   type="text/css"
   href="web.css" />
<link rel="stylesheet"
   type="text/css"
   media="print" 
   href="print.css" />
</head>
<body>
<div class="cls">Here is content of the DIV tag.</div>
</body>
</html>

then, the style sheet files would each define the class "cls" with the desired style info, except that the "cls" style info in the print version would exclude the height setting.
 
Thanks for the tip. The only reason i had the div tag in the first place was i needed to show a scroll bar for the contents of the page (since there is a Frame(Header) above that and dont want the header to scroll when the user uses IE Scroll bar) . If i can get the scroll bar anyother way and then still print at once it would be great . Else I can do what you suggested .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top