?
Solved

Script does not print pdf in IE 6.0

Posted on 2006-06-15
3
Medium Priority
?
211 Views
Last Modified: 2008-03-06
Hi,
 I have the following javascript which prints a PDF on click of a button. The script is supposed to open the print dialog box. It workd in IE 5.5 and FireFox but fails to work in IE .6.0. The following is the code:

function fn_printeport()
{
 var dummyVar;

   if(loadIframe("pdfWin", "../so/sodisplaypdf.do?rand="+Math.random()))
     {
       dummyVar = "dummyValue";        
     }
}

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;  
    return false;
  }
 
  else {
     return true;
  }
}

function fn_pdfprint()
{
var urlString = window.frames["pdfWin"].location.href;

if(urlString.indexOf("/so/sodisplaypdf.do") >= 0)
  {
  var delay="3000"; //delaying the print call (in ms)
  var string="fn_pauseforalert("+delay+");";
     //alert("javascript alert :Print will be delayed by "+delay+" ms");          
     setTimeout(string,delay);
  }
 

}


function fn_pauseforalert(delay)
{
 //alert("calling the print after delay of :"+ delay +" ms");

     var pdffileName = '<bean:write name="orderForm" property="salesOrderPDFFileName" />';    
     var pdffileName2 = '<bean:write name="orderForm" property="salesInvoicePDFFileName" />';    
 
 if(document.forms[0].printInvoice && pdffileName2!="")
  action="invoice";
 
 else if(document.forms[0].printOrder && pdffileName!="")
  action="delivery";
 
 
 
 if(action="")
 {
      alert("PDF not obtained.Please try again or later");
        return false;            
 }
 
 
 
 
 
 pdfWin.print();
 
}

IFRAMES are also being used:

<IFRAME   frameborder="0"  scrolling="auto" align = "top" hspace = 2 vspace = -300
width="100%" name="pdfWin" height="0" id="sup" onload="window.fn_pdfprint()">

Can anybody tell me why this happens?

Thanks,
Ajay.
0
Comment
Question by:ajaycv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 30

Accepted Solution

by:
callrs earned 500 total points
ID: 16910267
http://www.lissaexplains.com/forum/showthread.php?t=43641     Printing an iframe - Lissa Explains it All: Web Design Forums
http://www.codelifter.com/main/javascript/printframe.shtml     CodeLifter.com - JavaScript Print Page From Different Frame

Based on the above tips, try:

window.frames['pdfWin'].focus();
window.frames['pdfWin'].print();

(or possibly this:
pdfWin.focus();
pdfWin.print();


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question