Solved

Printing a specific frame on request

Posted on 1999-01-26
5
196 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now