Solved

Printing a specific frame on request

Posted on 1999-01-26
5
200 Views
Last Modified: 2013-12-25
I want to put a button/link in an asp page that will print the frame it's in (and only that frame) automatically. ANY suggestions welcome, but if the view is changed (another page loaded, etc), I need to be able to return to the current "view" without knowing what it looks like (I don't know what layout the "higher level" frames takes on).

A possible solution is to place a button which feeds keystrokes to the browser after the frame got focus. The keys would be CTRL-P, ALT-R, <ENTER> or some such. But how does one do that?
0
Comment
Question by:ayrezyle
[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
  • 4
5 Comments
 
LVL 1

Accepted Solution

by:
ptruman earned 100 total points
ID: 1859194
Bung this in your FRAME's HTML source :
<script language="JavaScript">
<!--
function tmt_print() {
    if (document.all) {
        var OLECMDID_PRINT = 6;
        var OLECMDEXECOPT_DONTPROMPTUSER = 2;
        var OLECMDEXECOPT_PROMPTUSER = 1;
        var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
        document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
        WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
        WebBrowser1.outerHTML = "";
    } else {
        self.print();
    }
}
//-->
</script>

Then in the BODY put an onload, so
<BODY onLoad="tmt_print()">

This WILL bring up the print window, theres NO way around
this....so it's not 100% automatic....but it does
do (unless overridden) the specified frame...

0
 
LVL 1

Author Comment

by:ayrezyle
ID: 1859195
That printed the whole set of frames. Each individually. When I moved the JScript call to an <A href= "JScript:tmt_print"> PRINT </A> tag in the relevant frame, it worked beautifully (printing just the focused frame)! Thanks!
0
 
LVL 1

Author Comment

by:ayrezyle
ID: 1859196
Problem: When I click OK in the popup it prints fine, but when I choose "cancel" it pops up the window _again_ and if I then click cancel again, it gives me a script error! How  do I correct this?
0
 
LVL 1

Author Comment

by:ayrezyle
ID: 1859197
Problem: When I click OK in the popup it prints fine, but when I choose "cancel" it pops up the window _again_ and if I then click cancel again, it gives me a script error! How  do I correct this?
0
 
LVL 1

Author Comment

by:ayrezyle
ID: 1859198
The problem is at the following line of code :
WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

738 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