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

Print button

P: n/a
Hi. On one particular web page I want to offer the user a print button.
Question. How do I create one? Something compatible with most browsers
would be nice. Appreciate any advice...Dennis
Oct 12 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Dennis Allen wrote:
Hi. On one particular web page I want to offer the user a print button.
Question. How do I create one? Something compatible with most browsers
would be nice. Appreciate any advice...Dennis

Printing is the function of the OS, although some UA's provide the
print method.
Mick
Oct 12 '05 #2

P: n/a
Dennis Allen wrote:
Hi. On one particular web page I want to offer the user a print button.
Question. How do I create one? Something compatible with most browsers
would be nice. Appreciate any advice...Dennis


You can add a button selectively for those browsers that support
window.print() by putting the following where you want the print
button to (optionally) appear:

<script type="text/javascript">
if(window.print){
document.write(
'<input type="button" value="Print this page"',
' onclick="window.print();">'
);
}
</script>

Browsers have a print button already, and keyboard shortcuts, so what
has been added?
--
Rob
Oct 12 '05 #3

P: n/a
In article <43***********************@per-qv1-newsreader-01.iinet.net.au>, RobG
says...

Dennis Allen wrote:
Hi. On one particular web page I want to offer the user a print button.
Question. How do I create one? Something compatible with most browsers
would be nice. Appreciate any advice...Dennis


You can add a button selectively for those browsers that support
window.print() by putting the following where you want the print
button to (optionally) appear:

<script type="text/javascript">
if(window.print){
document.write(
'<input type="button" value="Print this page"',
' onclick="window.print();">'
);
}
</script>

Browsers have a print button already, and keyboard shortcuts, so what
has been added?


With a pop-up window you can control if a toolbar displays or not. While some
people have enough experience to use a keyboard shortcut, it's a nice way of
presenting the print option without having to pull up the whole toolbar.

Rich
--
Newsguy -- http://newsguy.com

Oct 12 '05 #4

P: n/a
Thanks...Dennis

"RobG" <rg***@iinet.net.auau> wrote in message
news:43***********************@per-qv1-newsreader-01.iinet.net.au...
Dennis Allen wrote:
Hi. On one particular web page I want to offer the user a print
button. Question. How do I create one? Something compatible with
most browsers would be nice. Appreciate any advice...Dennis


You can add a button selectively for those browsers that support
window.print() by putting the following where you want the print
button to (optionally) appear:

<script type="text/javascript">
if(window.print){
document.write(
'<input type="button" value="Print this page"',
' onclick="window.print();">'
);
}
</script>

Browsers have a print button already, and keyboard shortcuts, so what
has been added?
--
Rob

Oct 12 '05 #5

P: n/a
ri**@newsguy.com wrote:
In article <43***********************@per-qv1-newsreader-01.iinet.net.au>, RobG
says...
[...]

Browsers have a print button already, and keyboard shortcuts, so what
has been added?


With a pop-up window you can control if a toolbar displays or not. While some


You can try, but you will likely fail at least some of the time.
people have enough experience to use a keyboard shortcut, it's a nice way of
presenting the print option without having to pull up the whole toolbar.


Some may question the logic of adding an unreliable UI element because
you deliberately removed the tool bar that may possibly have provided a
reliable one (I've chosen to remove the print button on mine).

The purpose of challenging logic is not necessarily to defeat it, but to
make whoever proposes it think the matter through thoroughly.

A print button in the page, if presented appropriately, will encourage
users to use it in preference to however else they may have attempted to
print the page. Many will do so in the belief that the button provides
some additional functionality that is not provided by the standard
browser print method (tool bar button, menu, keyboard shortcut,
whatever).

Having used your print button, should the print not actually gurgle
forth, the user may well believe the failure is your fault whether it is
or not.

In some browsers (IE at least), the tool bar print button sends the
print directly to the printer without presenting the print dialog - a
user who uses such a button in preference to, say, the file menu
probably likes that. By removing the tool bar button, you have denied
them the opportunity of using their preferred method and foisted yours
upon them.

If you have removed the tool bar but the browser doesn't support
window.print, you have removed a useful UI feature and not replaced it.

If, after thinking through the above (and whatever else you feel worth
considering on the subject), you still wish to remove the tool bar and
use an unreliable 'print' button that actually removes useful
functionality, at least you may have available more logical supporting
arguments. :-)
--
Rob
Oct 13 '05 #6

P: n/a
In article <rl*****************@news.optus.net.au>, RobG says...

ri**@newsguy.com wrote:
In article <43***********************@per-qv1-newsreader-01.iinet.net.au>, RobG
says...

[...]

Browsers have a print button already, and keyboard shortcuts, so what
has been added?


With a pop-up window you can control if a toolbar displays or not. While some


You can try, but you will likely fail at least some of the time.
people have enough experience to use a keyboard shortcut, it's a nice way of
presenting the print option without having to pull up the whole toolbar.


Some may question the logic of adding an unreliable UI element because
you deliberately removed the tool bar that may possibly have provided a
reliable one (I've chosen to remove the print button on mine).

The purpose of challenging logic is not necessarily to defeat it, but to
make whoever proposes it think the matter through thoroughly.

A print button in the page, if presented appropriately, will encourage
users to use it in preference to however else they may have attempted to
print the page. Many will do so in the belief that the button provides
some additional functionality that is not provided by the standard
browser print method (tool bar button, menu, keyboard shortcut,
whatever).

Having used your print button, should the print not actually gurgle
forth, the user may well believe the failure is your fault whether it is
or not.

In some browsers (IE at least), the tool bar print button sends the
print directly to the printer without presenting the print dialog - a
user who uses such a button in preference to, say, the file menu
probably likes that. By removing the tool bar button, you have denied
them the opportunity of using their preferred method and foisted yours
upon them.

If you have removed the tool bar but the browser doesn't support
window.print, you have removed a useful UI feature and not replaced it.

If, after thinking through the above (and whatever else you feel worth
considering on the subject), you still wish to remove the tool bar and
use an unreliable 'print' button that actually removes useful
functionality, at least you may have available more logical supporting
arguments. :-)


Thanks for the feedback RobG. With Javascript it's a bit difficult being
completely cross browser
compliant. It's unfortunate that UI features like print or scroll bar colors are
not consistently supported
across browsers. Can have a site that looks really nice on one and really crappy
on another.

I don't use pop up windows very often because of the obvious negative
connotations, but in instance
that I do, I prefer to use a "scaled" down window so only the necessary
information is displayed.
Aesthetically speaking it's a shame to have to load a complete toolbar when the
print button itself may
rarely be used. Appreciate your feedback.

Rich
--
Newsguy - http://newsguy.com

Oct 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.