Solved

ATTN mplungjan: Print an HTML-page automatically

Posted on 1998-08-25
1
200 Views
Last Modified: 2013-12-25
How do I automatically print an HTML-page (using JavaScript)?
0
Comment
Question by:mnprsd
1 Comment
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 100 total points
ID: 1854569
This will put a button to print on the page:
       <object id=WBControl width=0 height=0
       classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2></object>

       <SCRIPT LANGUAGE=VBScript><!-- //
          Sub VBPrint() On Error Resume Next
             WBControl.ExecWB 6,1
          End Sub
       // --></SCRIPT>
       <SCRIPT LANGUAGE=JavaScript><!-- //
          if (navigator.appName.indexOf('Microsoft') !=-1)
             document.write('<FORM><INPUT TYPE="BUTTON" ONCLICK="VBPrint()" value="Print"></FORM>');
          else if (self.print)
             document.write('<FORM><INPUT TYPE="BUTTON" ONCLICK="self.print()" value="Print"></FORM>');
       // --></SCRIPT>

To print without user interference, just put

       <SCRIPT LANGUAGE=JavaScript><!-- //
          if (navigator.appName.indexOf('Microsoft') !=-1) VBPrint();
          else if (self.print) self.print();
       // --></SCRIPT>

Michel
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now