JavaScript print preview?

Create a new stylesheet (in this example, I've named it "print. Css") and include it in your HTML as follows: link rel="stylesheet" href="print. Css" type="text/css" media="print Note the media="print —this means the stylesheet will only be used when printing the page Next assign a class to your a element so that we can reference it in CSS: a href="javascript:window.print()" class="noPrint">Print this Page.

Addressing the following part of your question: in the print "print this page also printed . How can I hide it? Create a new stylesheet (in this example, I've named it "print.

Css") and include it in your HTML as follows: Note the media="print"—this means the stylesheet will only be used when printing the page. Next assign a class to your element so that we can reference it in CSS: Print this Page Finally, in your CSS file, include the following rule: . NoPrint { display: none; } Now the "Print this Page" link shouldn't appear in the printed version of your page.Steve.

1 Or add a meaningful class-name 'no-print', and have that no-print {display: none;}, and apply that to all items that are irrelevant or unwanted in the printed version. – David Thomas Jul 7 '09 at 10:43 @drthomas: Good idea! I've updated my answer accordingly.

– Steve Harrison Jul 7 '09 at 11:17.

You can create separate print stylesheets to have some general control over how a site will look in print. You can display the site to your user using this special print stylesheet before printing. That does not give you a 100% preview though, as every browser handles things a bit differently.

You won't see how it prints until it actually prints. Using a print stylesheet will get you pretty close though. Some operating systems and printer drivers offer a preview to the user between hitting the Print button and the actual print, but that's not something you have control over or that's guaranteed to always be available.

Browsers don't offer an API to trigger the print preview feature in browsers. Happily, they almost all keep it in the usual place (dangling from the File menu), so you shouldn't have to draw users' attention to it.

– rahul Jul 7 '09 at 6:43 3 No! No! No!

No! No! No!

No! No! No!

No! No!(Stackoverflow has a minimum comment length) – Quentin Jul 7 '09 at 6:58 4 Let the browser handle the print preview. Include a print stylesheet that makes your invoice page look nice when printed (this is a good thing to do for any webpage), and if you want, include a "Print this Page" link, but let the browser handle browser-based tasks.

– Steve Harrison Jul 7 '09 at 7:22.

You can get the current page to print by calling window.print(). For example: Print this page If you are wanting to give them some idea of what it will look like printed, you can use the script on this page to give them a pseduo-preview of the way the page with print.

This is for print. But I need to preview before printing – rajanikant Jul 7 '09 at 6:36 one thing more that when I take print with this script then print this page is also printed. How can I hide this?

– rajanikant Jul 7 '09 at 6:44 1 Actually, a pseudo-preview is the closest you can get inside the browser. Pseudo-preview means in this case, that all 'screen' targeted stylesheets are removed, and all 'print' targeted stylesheets are applied. No paging, sorry.

– Boldewyn Jul 7 '09 at 7:06.

To directly answer your question, when you call the Browser print() method it prints the page as-is. If you want to print a different version of the page (without the "Print this page" element, for example), you will need to create a separate Printable version of the page (usually done using a separate stylesheet) which does not have those elements you do not want on the Printed page.

To hide the link when printing, do this: print this page Alternatively: print this page Although this won't reappear after cancelling the print.

Function Print( ) { document. GetElementById('ImagePrint').style. Visibility='hidden'; window.print(); document.

GetElementById('ImagePrint').style. Visibility='visible'; } in html body print Info This function will not show your image in printing. You can use your control rather than image with control id.

Hope you will get your solution.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions