Connecting Tech Pros Worldwide Forums | Help | Site Map

printing problem in frames using javascript

meenakshia's Avatar
Member
 
Join Date: Jun 2008
Location: delhi,india
Posts: 33
#1: Sep 9 '08
hi forum
i m facing a problem regarding printing withing the frames page
i have a main frame page. which has on the left the menu html page loaded and on the right the target content page.
when i try to open a page on the right and print two different pages using iframes it does not work ,
on the contrary when i load the page without frames it does the print job perfectly.i fail to understand why this is happening
i m posting the partial code as the main code is too long and is not relevant for this issue.
the following is the code
pls suggest me some way out
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2.  
  3. function printPg(ifrmname){
  4.             if(top.frames[ifrmname]){
  5.                 top.frames[ifrmname].focus();
  6.                 top.frames[ifrmname].print();
  7.             }
  8.         }
  9. </script>
  10. <td>
  11. <iframe name="one" width="0" height="0" frameborder="0" src="E:/anand/program/final/databaseos/data/custprint.htm"></iframe>
  12.  
  13. <iframe name="two" width="0" height="0" frameborder="0" src="E:/anand/program/final/databaseos/data/factprint.htm"></iframe>
  14.  
  15. <a href="#" onclick="printPg('one');return false;">Print Customer Copy</a>
  16.  
  17. <a href="#" onclick="printPg('two');return false;">Print Factory Copy</a>
  18. </td>
  19.  
---smile always
anand

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Sep 10 '08

re: printing problem in frames using javascript


I haven't tested, but I don't think the iframes within a frame will be in the main page frames array. You could use JavaScript to make the print style sheet change to the selected iframe when a link is clicked.
meenakshia's Avatar
Member
 
Join Date: Jun 2008
Location: delhi,india
Posts: 33
#3: Sep 10 '08

re: printing problem in frames using javascript


hi
problem solved
i used a hit and trial method with success:)
top.frames[ifrmname]
i removed top as it was not refering to right frame and it worked:)
thanks anyways
smile always
anand
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Sep 10 '08

re: printing problem in frames using javascript


So frames[ifrmname] worked? It should do.

Anyway, glad you've got it to work.
Reply


Similar JavaScript / Ajax / DHTML bytes