By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,068 Members | 899 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,068 IT Pros & Developers. It's quick & easy.

printout from website

P: n/a
Is it possible (if yes, how to do that?). I want to put on my website a
button. If you click the button the printing of the website will start on
your local printer.
I know, you can print that from Internet Explorer menu bar but I want to do
that by clicking my own button on my own website
Feb 6 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Sure. A javascript call print() will do:

<input type="button" value="Print" onclick="window.print()" />

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:4C**********************************@microsof t.com...
Is it possible (if yes, how to do that?). I want to put on my website a
button. If you click the button the printing of the website will start on
your local printer.
I know, you can print that from Internet Explorer menu bar but I want to
do
that by clicking my own button on my own website

Feb 6 '07 #2

P: n/a
thx man!

is it possible to show a preview as well? Anyway, that is not important...
ok, I put a button on website. print() method works fine, but on the
printout there is also the button. Any ideas how to remove that?

"Eliyahu Goldin" wrote:
Sure. A javascript call print() will do:

<input type="button" value="Print" onclick="window.print()" />

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:4C**********************************@microsof t.com...
Is it possible (if yes, how to do that?). I want to put on my website a
button. If you click the button the printing of the website will start on
your local printer.
I know, you can print that from Internet Explorer menu bar but I want to
do
that by clicking my own button on my own website


Feb 6 '07 #3

P: n/a
No, you are limited to whatever your browser's print dialog provides.

To remove the button for printing, handle the onbeforeprinting and
onafterprinting events. You can set them in the <bodytag. You will need to
add an id to the button and hide the button in the onbeforeprinting as
myForm.myButton.style.visibility="hidden" and show it in the onafterprinting
event as myForm.myButton.style.visibility="visible".

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:CB**********************************@microsof t.com...
thx man!

is it possible to show a preview as well? Anyway, that is not
important...
ok, I put a button on website. print() method works fine, but on the
printout there is also the button. Any ideas how to remove that?

"Eliyahu Goldin" wrote:
>Sure. A javascript call print() will do:

<input type="button" value="Print" onclick="window.print()" />

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:4C**********************************@microso ft.com...
Is it possible (if yes, how to do that?). I want to put on my website a
button. If you click the button the printing of the website will start
on
your local printer.
I know, you can print that from Internet Explorer menu bar but I want
to
do
that by clicking my own button on my own website



Feb 6 '07 #4

P: n/a
Thx again. That works :)

Last question: at the bottom of the printout There are date and path to the
source file of the website. Is it possible to reformat the date and delete
the path or change it to my own text?
Feb 6 '07 #5

P: n/a
No, those are provided by the client's browser. You can't control them.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Chris" <Ch***@discussions.microsoft.comwrote in message
news:62**********************************@microsof t.com...
Thx again. That works :)

Last question: at the bottom of the printout There are date and path to
the
source file of the website. Is it possible to reformat the date and delete
the path or change it to my own text?

Feb 6 '07 #6

P: n/a
is it possible to show a preview as well? Anyway, that is not important...
ok, I put a button on website. print() method works fine, but on the
printout there is also the button. Any ideas how to remove that?
Another solution is to have separate screen and print stylesheets
using the media="" attribute in the stylesheet links. Not only can
you remove the button by applying the "display:none;" attribute to its
class but you can reformat other elements on the page based on their
classes to produce a much more elegant printout.
Feb 7 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.