473,516 Members | 3,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print button

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
6 2887
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8340
by: Craig | last post by:
First of all, this one is driving me crazy, so thanks in advance for any help!! I've got a javascript function in a parent document that generates an HTML document on the fly when a button is clicked... that generated popup contains a button that's supposed to print the contents of the popup window (self). However, the button won't print...
2
2866
by: Asad | last post by:
I have a main window that creates a new window called printWin (which contains the printable format of the page). From the main window I embed a javascript in the printWin window that calls the "window.print()" function. So it looks like this: printWin.document.write ("<FORM>"); printWin.document.write ("<INPUT TYPE=\"BUTTON\"...
4
2344
by: rom | last post by:
I need to print a html table when the user clicks on a key. the problem is that i don't want the printer dialog box to appear. i guess this is impossible in javascript so i think to create an event that will be fired by a keyup event, this event will submit the page, and i will be able to print in from the vb.net without the printing dialog...
1
5686
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out of a Microsoft book, "Visual Basic,Net Step by Step" in Chapter 18. All but the bottom two subroutines will open a text file, and then allow me...
4
3045
by: Peter | last post by:
ASP.NET 1.1 Does anyone has an example where user can click on an link or button and print the current page? Thanks Peter
10
3777
by: jon | last post by:
I'm trying to use a hidden iframe to print the contents of one div seamlessly. Currently I can create the hidden iframe, copy the contents of the div to the iframe, and print it. I even have a method that initially copies all the original page's styles onto the new iframe to maintain look and feel. So far things work, and the div (along...
2
9167
by: =?Utf-8?B?RGlmZmlkZW50?= | last post by:
Hello All, I am trying to offer "Print" functionality using an HTML button with the help of "window.print()" This button works fine in Firefox but not in IE7. I am dumping the entire content of the page which has this HTML button code onto a different page using document.write. Everything else works fine except for this print button. I...
7
3408
by: Fareast Adam | last post by:
I try to hide the print preview button that inside <div id="button"> when previewing the page. But the the problem happened the button is always hidden after i closing the preview page. Anyone have an idea how to overcome this? Here is the code; <html> <head> <script language="javascript"> function printpreview() { var OLECMDID = 7; ...
3
5250
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
I have an application that hosts a web browser control. I would like to detect when ever the browser tries to print a page and rather than print the document, store the print job off in a database for printing at a later time. There are some other controls in my application that the user could print from, so I can't have this specifically...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3267
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.