Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •