?
Solved

Printing with HTML

Posted on 1999-06-28
12
Medium Priority
?
283 Views
Last Modified: 2010-04-09
Can you print from a button on a framed page? i.e. I have a page with a navbar and certian pages of my site folks might want to print out, but I don't want them to waste time printing out the navbar, just the relevant stuff as if it were a full witdh page.
Cheers, Rob.
0
Comment
Question by:robjohnston
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 7

Expert Comment

by:nettrom
ID: 1851251
self.print() won't do?  if not, then how 'bout opening a child window and print its contents instead?
0
 
LVL 1

Author Comment

by:robjohnston
ID: 1851252
Didn't know about self.print() I'll give it a whirl and get back to you.
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 1851253
The print() function will do this for NetScape.

 In IE you can include print.js -- see this site:
   http://msdn.microsoft.com/workshop/Author/script/DHTMLPRINT.asp

 and download this file:
    http://msdn.microsoft.com/workshop/Author/script/print.js 

 Once you include print.js, a print button can be done like this:

   <INPUT type='button' name='cmdPrint' value='Print' onClick='print()'>

 For more examples see:
    http://msdn.microsoft.com/workshop/Author/script/samp1.htm 
    http://msdn.microsoft.com/workshop/Author/script/samp2.htm 
    http://msdn.microsoft.com/workshop/Author/script/samp3.htm 

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 33

Expert Comment

by:knightEknight
ID: 1851254
left out the "self":

 <INPUT type='button' name='cmdPrint' value='Print' onClick='self.print()'>
0
 
LVL 6

Accepted Solution

by:
tecbuilder earned 200 total points
ID: 1851255
The only way that you can print exactly what you want is to open a new window or update a frame with what you want to have printed.  Browsers cannot print only certain parts of a window (except for framed windows) or certain parts of a frame.  It's all or nothing.  The information supplied above concerning a print.js script is JScript not JavaScript, meaning Netscape browsers will not work with this script.  Also, the print.js will only work with IE 4.x and later browsers.  The self.print function will only work with 4.x version browsers and it to will print the entire window or frame.
0
 
LVL 7

Expert Comment

by:nettrom
ID: 1851256
tecbuilder, I don't see anything new come up in your reply.  what does it matter that print.js is Jscript, kEk correctly stated it was for IE as print() works in IE5/NN4.  I already mentioned opening the child window or using self.print() as kEk also stated...
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 1851257
Yes, the code above will work in NetScape regardless of print.js ...
0
 
LVL 6

Expert Comment

by:tecbuilder
ID: 1851258
The information I provide includes more specifics than generalities.  print.js may work fine in some of the later versions of Netscape 4.x, but are you sure it will work in -all- versions of Netscape.  Netscape 3.x doesn't interpret JScript and the last I heard, Netscape is still widely in all versions.  Also, what about those people who are not using IE4x or NS 4.x or later versions?

kEk did not mention that print.js will only work in IE 4.x as well.  As I interpretted his comment, it would work for all versions.  As for your comment, it seemed vague.  You said to open a child window and print it's contents.  What contents are you referring to?  It also seemed to me that you were unsure of your response.  My comments here are not to thrash you or kEk.

tecbuilder
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 1851259
tecbuilder, you miss the point...
print.js will have no effect on NetScape browsers because the first thing it does is check to see if window.print is a valid function, and if so, it does nothing else.  Therefore, window.print() will still work in NetScape as always.

print.js emmulates window.print() for IE -- which IS the point.  Since window.print() is not implemented in IE4 and below, print.js creates the function, so the code below will now work in IE4+ and NS3+ and perhaps earlier versions as well (I haven't tested)

<INPUT type='button' name='cmdPrint' value='Print' onClick='self.print()'>
0
 
LVL 6

Expert Comment

by:tecbuilder
ID: 1851260
I didn't miss the point, though I may not have stated my viewpoint well enough to make this clear.  Since print.js will have no effect on Netscape or IE 3.x browsers the necessary end result is not met (wanting to print just some part of a page), however what would happen is that the entire page would be printed.  Therefore the necessary end result has not been met.  Another way to say this, is that since print.js will only work for IE 4 and 5 and nothing else then the end result has not been accomplished.  Hence, the need for a solution that will work with at least the vast majority of browsers and their many versions.

tecbuilder
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 1851261
Ah.

If I read the question correctly, he wants to be able to print the contents of frame A from a button on frame B.  If so, then print() will work (with print.js in IE) by calling the print() method of frame A from the onClick of the button on frame B.  

If your reading of the question is correct -- that is, he only wants to print just part of a single page, then I agree, I don't see any way around that.
0
 
LVL 6

Expert Comment

by:tecbuilder
ID: 1851262
I too now see what you reading as well.  :-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question