Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-26-2002, 07:51 PM   PM User | #1
allida77
Regular Coder

 
Join Date: Jun 2002
Location: Cincinnati, OH
Posts: 545
Thanks: 0
Thanked 0 Times in 0 Posts
allida77 is an unknown quantity at this point
printing within an iframe

I know how to print and iframe from the parent:

document.frames('iPrint').focus();
document.frames('iPrint').print();

but how do you print from the iframe itself. I am passing an id from the parent to the iframe and then submitting the form on the iframe to call an sub that produces the html content. If I try to print from the parent the sub takes to long to run so it prints a blank page. I am trying to add a print block at the end of the sub so whenver it is through loading it will print itself.

iframe:
Code:
<%
Sub mySub()
    a bunch of code
    'at the end write out javsscript

   ******THIS IS THE PROBLEM****
  <script>window.print()</script>   ---doesnt do anything
  <script>document.frames('iPrint').focus();
document.frames('iPrint').print();</script> ----throws an error ("Exception")
**************************
End Sub
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<link rel="STYLESHEET" type="text/css" media="print" href="media/print.css">
</HEAD>
<BODY>
<form name="frmPrint" method="post" action="print.asp">
<input type="hidden" name="hdnagtmgrID">
</form>
<%
If Len(Request.Form("hdnagtmgrID")) > 0 Then
	AgcyChgs(Request.Form("hdnagtmgrID"))
End If	
%>
</BODY>
</HTML>

Thanks in advanvce

Last edited by allida77; 11-26-2002 at 09:44 PM..
allida77 is offline   Reply With Quote
Old 11-26-2002, 09:43 PM   PM User | #2
allida77
Regular Coder

 
Join Date: Jun 2002
Location: Cincinnati, OH
Posts: 545
Thanks: 0
Thanked 0 Times in 0 Posts
allida77 is an unknown quantity at this point
ok I am now just calling a print function on my parent page after the iframe is loaded but I have now run into a bug.

Code:
function submitIFrame(id) {
	var oifrmNode = document.frames("iPrint").document.frmPrint.hdnagtmgrID
	oifrmNode.value = id;
	document.frames("iPrint").document.frmPrint.submit();


}
	
function printIFrame() {
alert("you called");
	document.frames('iPrint').focus();
	document.frames('iPrint').print();
}
The printIFrame() is what I call from the iframe. The alert msg pops up but it never prints and the status bar on the bottom of the browser slowly chugs along and stops halfway. Any see anything I could change?
allida77 is offline   Reply With Quote
Old 11-26-2002, 10:01 PM   PM User | #3
allida77
Regular Coder

 
Join Date: Jun 2002
Location: Cincinnati, OH
Posts: 545
Thanks: 0
Thanked 0 Times in 0 Posts
allida77 is an unknown quantity at this point
ok I figured it out I should post my problems more often.
FYI:

Code:
function submitIFrame(id) {
	var oifrmNode = document.frames("iPrint").document.frmPrint.hdnagtmgrID
	oifrmNode.value = id;
	document.frames("iPrint").document.frmPrint.submit();
                document.frames('iPrint').focus();


}
	
function printIFrame() {
alert("you called");
      window.print();
}
The status bar still looks like it is loading something but as long as it works....
allida77 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:32 AM.


Advertisement
Log in to turn off these ads.