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 7 of 7
  1. #1
    New Coder
    Join Date
    Oct 2003
    Location
    Ukraine
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print/preview shows only 1 first print page for the iframe

    Hi,

    Let me describe problem.
    I have multiple iframes on the page.htm and and I want to print them all with
    window.print() call on page.htm. I resize iframes to the size of document they contain.
    Now when I open Print Preview in IE 6 (loaded with page.htm) it shows me only 1 first print_page for each iframe, even if document in the iframe has more that 1 print_page.
    Say I have 2 iframes on the page.htm and each iframe has a document that produces 2 print_pages (if that document opened separately) and number of pages shown in the Print Preview should be 4 but I see only 2, eq. 1 first print_page for each document.

    Is it possible to make IE 6 (and in NS 6 if possible) to preview and then print All print_pages for each of iframes my page.htm contain ?
    Are there any APIs except of (window.print() and 2 CSS styles) to have more control on printing ?

    Thanks

    Slava

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Is there any compelling reason you're using iframes?

    Normally, you can only print one window, frame or iframe at a time. One possible workaround is to have an invisible iframe and put the contents of the desired iframes there.
    Code:
    function printIFrames(){
      var html='<html><body>';
      for (var i=0;i<window.frames.length;i++){
        if (window.frames[i].name!="printFrame") html += window.frames[i].document.body.innerHTML;
      }
      html += '</body></html>';
      var printFrame = window.frames["printFrame"];
      printFrame.document.write(html);
      printFrame.document.close();
      printFrame.focus();
      printFrame.print();
    }
    ...
    <iframe src="page1.htm"></iframe>
    <iframe src="page2.htm"></iframe>
    ...
    <iframe name="printFrame" src="about:blank" style="display:none"></iframe>
    <input type="button" value="Print" onclick="printIFrames()" />

  • #3
    New Coder
    Join Date
    Oct 2003
    Location
    Ukraine
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Glenngv,

    Thanks for your reply.
    Reason is I need to print multiple different pages from different web sites as a one print job.
    So I decided to try to put them in separate iframes of one page.htm and call window.print() on it.
    I can call window.print() on each iframe in onload event but user would see may popup print dialogs and click print many times.
    I could put all page's content into a one iframe or just on the page.htm
    but those pages are different documents and can contain any scripts etc.
    so I don't think it would work at all.

    Slava

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    You have no chance of making it worked if the pages are in a different domains. For security reasons, you have no access to the frames/iframes that points to external pages.

  • #5
    New Coder
    Join Date
    Oct 2003
    Location
    Ukraine
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, I've found out that (a couple of days before) that
    window.document.frames[i].document produces access denied error.

    But I want to add that I have all those pages texts (I want to print together)in my mssql table (in the ntext field). So I am free to add anything into those pages on fly. I added a call to my function SetFullSize() to resize iframe (in hope it could be printed) into each page's onload handler, so if SetFullSize() is called from iframe's document it can access window.document.frames[i].document.
    My multi-iframed page.htm is actually page.aspx.

    Slava

  • #6
    New Coder
    Join Date
    Oct 2003
    Location
    Ukraine
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thinking maybe I should not use those iframes but write some little COM object with ATL and print everything from it ?
    Just those COM object security problems stop me.

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Quote Originally Posted by SlavaTT
    But I want to add that I have all those pages texts (I want to print together)in my mssql table (in the ntext field). So I am free to add anything into those pages on fly. I added a call to my function SetFullSize() to resize iframe (in hope it could be printed) into each page's onload handler, so if SetFullSize() is called from iframe's document it can access window.document.frames[i].document.
    My multi-iframed page.htm is actually page.aspx.

    Slava
    If you have all their data in your db, then make a single page that accesses your db and print that single page.


  •  

    Posting Permissions

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