Help and Support

Article ID: 247671 - Last Review: May 12, 2003 - Revision: 2.0

PRB: Printing with WebBrowser from Internet Explorer Raises Print Dialog Box in Internet Explorer 5

This article was previously published under Q247671
Expand all | Collapse all

SYMPTOMS

Developers wishing to print multiple copies of an HTML page from script sometimes try to host the WebBrowser control and call ExecWB() repeatedly with the OLECMDID_PRINT command and the OLECMDOPT_DONTPROMPTUSER option. However, this always brings up a print dialog box for each print request. This command works as intended in a WebBrowser host or an ActiveX control. It also works in some versions of Microsoft Internet Explorer Version 4.0.

CAUSE

This was a security hole. Consider the following code:
for (var i = 0; i < 100000; i++) {
    WebBrowser1.ExecWB 6, -1
}
				
If allowed to execute, this amounts to a Denial of Service attack, wherein it is possible to jam the user's systems by flooding them with repeat requests.

Additionally, the WebBrowser control's events cannot be sunk when the control is hosted within Internet Explorer. Therefore, there is no way of knowing when a document has completely loaded and is ready to print. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
183048  (http://support.microsoft.com/kb/183048/EN-US/ ) PRB: Events Not Firing When IE4 WebBrowser Placed On Web Page

RESOLUTION

There is currently no easy method for printing multiple pages programmatically from script without bringing up a dialog box.

Developers should re-evaluate their use of the WebBrowser control within HTML pages. The WebBrowser control was not designed to be hosted on a Web page using an OBJECT tag.

STATUS

This behavior is by design.

APPLIES TO
  • Microsoft Internet Explorer 5.0
  • Microsoft Internet Explorer 5.01
Keywords: 
kbprb kbprint kbwebbrowser KB247671
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

Article Translations

 

Related Support Centers