?
Solved

Auto Printing of HTML page

Posted on 2003-03-18
18
Medium Priority
?
711 Views
Last Modified: 2010-04-06
How to I print a web page by clicking a button and it does not promte me the print dialog. It just go to printing straight away by printing to the default printer..
What the best way to do it
0
Comment
Question by:victkh
  • 6
  • 4
  • 3
  • +3
18 Comments
 
LVL 2

Expert Comment

by:yyilmaz
ID: 8164169
On IE 5.5,
<a href="#" onClick="window.print();return false">print</a>

promts for the print dialog.
0
 
LVL 3

Expert Comment

by:allahabad
ID: 8164245
You can't for html page; You will have use to onClick="Javascript:Window.print()" on the button,and this will pop up normal print window of the browser.
0
 

Author Comment

by:victkh
ID: 8164339
but I don't want the print dialog to appear and it will just print
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Expert Comment

by:yyilmaz
ID: 8164366
OH, I see - from your question I figured you WANTED the print dialog. :-) So I was confused as to how you managed to "not get the dialog".

Hmm no answer from me I'm afraid. I do believe it should be possible though.
0
 

Author Comment

by:victkh
ID: 8164486
I just want to print the web page, if it is in ASP format? will i be able to do that..

For e.g. there a print button located in IE tool Bar(where u find "history", "favourites" button), when u click it, it just print without the print dialog...
0
 

Expert Comment

by:paulie134
ID: 8165097
In I.E 6 there are a load of new printing functions but i believe that this is not one of them, although i have only scanned the white paper. There is info on the MS site. I can imagine it could become a nuisance if site developers could print without first prompting the user
0
 
LVL 7

Expert Comment

by:markhoy
ID: 8165156
NO! this is a security feature, otherwise hackers etc could send print jobs to your printer!
0
 

Author Comment

by:victkh
ID: 8165341
what if it an intranet not on internet?
I set up an IIS
0
 

Expert Comment

by:paulie134
ID: 8165357
still the same, the IE document object model (DOM) does not allow for it.
0
 
LVL 14

Accepted Solution

by:
avner earned 200 total points
ID: 8165565
The only way to do this , is using Active X :
<html>
<head>
<title>about:blank</title>
<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');
}
-->
</script>
<style>

</style>
</head>
<body onload="print()">

</body>
</html>
0
 

Expert Comment

by:paulie134
ID: 8165727
Wow that actually works, full marks if i could give them to you. Thanks you have actually just solved a long running problem of ours
0
 
LVL 14

Expert Comment

by:avner
ID: 8165740
BTW : do not abuse this script, many users would want people to force them to print something..


victkh , Does this solves your problem too ?
0
 

Author Comment

by:victkh
ID: 8171023
wow it work pefectly thx
0
 

Author Comment

by:victkh
ID: 8171132
I think I maybe asking for too much is it possible to select printers as well from the web page?
0
 
LVL 14

Expert Comment

by:avner
ID: 8171782
victkh , Defiantly not.
0
 

Expert Comment

by:paulie134
ID: 8172414
There are ways of actually doing this, if scripting is enabled in the browser then it is possible using the Script Host or if you build VB/C dll and digitally sign it and maerk it safe for scripting then this can be done. However opening up the browser as scripting enabled is a bit of a secuirty risk and if yo have no knowledge of VB/C then the dll is a no no as well. Do you have VB/C skills?
0
 

Author Comment

by:victkh
ID: 8178266
yah abit of VB skills
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

569 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