Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

Need a button on a web page, that can auto print to the default printer (meaning, without the print options box popping up)

Hi all.
To be more specific im looking for this button to do three things upon clicking it:

1. Take the data that the user inputs via a form on the same page (Name, Company, Person visiting, Phone number etc...)and add it to a .CSV file.
2. Print a selcect few of the form fields (Name and Company + predefined logo) to a label printer (the only printer on the machine which is attached to lpt0) with out any other boxes popping up.
3. Move to a confimation page.

So I have 1. and 3. figured out and working with frontpage server extensions. Is there any way i can make this same button print immediately without asking the user to choose a printer? ActiveX control maybe?

I know on the Microsoft web site they have done this in the MCP section when asking to print a transcript of your exams. there is a button that does just want i want. but i know there is some ActiveX control code attached to it, and am looking for someone who has free code to let me use, or for someone to explain how it is done, or to point me in the right direction for a tool that will help me do that, and how to use that tool. (i have Microsoft ActiveX control Pad).
  • 2
  • 2
1 Solution
Using an Active X is the only way :

<script language="javascript1.2">
<!-- copyright(c) avcoh@yahoo.com
function print() {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);

    execScript("on error resume next: WebBrowser1.ExecWB 6, -1", "VBScript");
    execScript('on error resume next: WebBrowser1.outerHTML = ""', 'VBScript');

test page <button onclick="print()">print !</button>

petegreenupAuthor Commented:
Ok great!!! this prints the same webpage, is there anyway i can print either a hidden frame or a spcified part/section of the page. ie just a couple of fields from the form?
The only way you can print parts of the page is by adding CSS to explicity set parts of the page to be hidden.

For example if you have button you don't want to display :

<button class="noprint">don't print me</button>

Then in the style tag :

@media print  
This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

Unless it is clear to me that the question has been answered I will recommend delete.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

If the user does not know how to close the question, the options are here:


It is time to clean this abandoned question up.

I am putting it on a clean up list for CS.

popints to avner


If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.



Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now