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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print content only 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I need to put a button on a page and have it be a print button, that will print only whats on the html page (a jpeg) nothing else, just print the picture, (not like printing from the browser menu, which would include everything on page etc), I just want the user to be able to print the “content”
Thanks
 
create a form with a print button on the page you want to print from:

Code:
<form>
<input name=&quot;Print&quot; onClick=&quot;window.print()&quot; type=&quot;button&quot; value=&quot;Print&quot;>
</form>

place the following tag between the head tags:

Code:
<link rel=alternate media=print href=&quot;printcontent.html&quot;>

create a separate new page called &quot;printcontent.html&quot; that contains only the content that you want to print.

hope this helps...


 
Nice trick, xjs!
star.gif
++ Good Luck! :)
 
this also works to print other file types like a word document, not just html.

Code:
<link rel=alternate media=print href=&quot;printcontent.doc&quot;>
 
So you mean that I see HTML document but get Word printed? Nice! Does it work only with IE or NN and Opera supports it too? Good Luck! :)
 
it looks like it works in ie only. you see the html, word doc gets printed. i just tried/tested it in nn and it doesn't work at all. (i should have known that. thanks for keeping me honest.)

nn 4.08 printed the actual html page, not the alternate file. use javascript to sniff the browser and render the print button if ie.

i don't know anything about opera.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top