Solved

Script does not print pdf in IE 6.0

Posted on 2006-06-15
3
203 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
3 Comments
 
LVL 30

Accepted Solution

by:
callrs earned 125 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now