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 07-14-2004, 10:48 AM   PM User | #1
SlavaTT
New Coder

 
Join Date: Oct 2003
Location: Ukraine
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
SlavaTT is an unknown quantity at this point
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
SlavaTT is offline   Reply With Quote
Old 07-14-2004, 11:18 AM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
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()" />
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app

Last edited by glenngv; 07-14-2004 at 11:22 AM..
glenngv is offline   Reply With Quote
Old 07-14-2004, 11:46 AM   PM User | #3
SlavaTT
New Coder

 
Join Date: Oct 2003
Location: Ukraine
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
SlavaTT is an unknown quantity at this point
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
SlavaTT is offline   Reply With Quote
Old 07-14-2004, 11:59 AM   PM User | #4
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
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.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 07-14-2004, 12:17 PM   PM User | #5
SlavaTT
New Coder

 
Join Date: Oct 2003
Location: Ukraine
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
SlavaTT is an unknown quantity at this point
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
SlavaTT is offline   Reply With Quote
Old 07-14-2004, 12:24 PM   PM User | #6
SlavaTT
New Coder

 
Join Date: Oct 2003
Location: Ukraine
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
SlavaTT is an unknown quantity at this point
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.
SlavaTT is offline   Reply With Quote
Old 07-15-2004, 03:34 AM   PM User | #7
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
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.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv 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 05:58 PM.


Advertisement
Log in to turn off these ads.