?
Solved

Auto Printing of HTML page

Posted on 2003-03-18
18
Medium Priority
?
707 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

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…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
The viewer will learn how to count occurrences of each item in an array.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

770 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