Solved

Printing a specific frame on request

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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

635 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