Solved

Script does not print pdf in IE 6.0

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

688 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