Solved

Script does not print pdf in IE 6.0

Posted on 2006-06-15
3
204 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sums of coloumns in html/java 15 67
How to change pointer icon to hand icon on mouseover 2 19
using php variable inside javascript 5 15
how can i extend ? 2 6
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

895 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

15 Experts available now in Live!

Get 1:1 Help Now