views:

47

answers:

1

Hello Everyone,

i m trying to pickup contents of a div and open it in new window using window.open so user can print this printer friendly page. i have got the code somewhere on the net and made some modifications. below is the code snippet

function printpage() {
      var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
      disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25";
      var content_vlue = document.getElementById("memo_data").innerHTML;
      var somestyle = '<style type="text/css"> #memotxt p {padding:0 0 0 0;margin:5px 0 0 0;}</style>';  

  var docprint=window.open("","sa",disp_setting); 
   docprint.document.open();
   docprint.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;head&gt;&lt;title&gt;Inter Office Memo</title>');
   docprint.document.write('<link type="text/css" rel="stylesheet" href="../../Content/style.css"');
   //docprint.document.write(somestyle);
   docprint.document.write('</head><body><fieldset style="border:none;"><div class="memo-report-top"');          
   docprint.document.write(content_vlue);          
   docprint.document.write('</div></fieldset></body></html>'); 
   docprint.document.close(); 
   docprint.focus(); 

     }

when i open this page in firefox it works exactly the way it is supposed to but when i open page in IE8 and press print button that triggers printpage() function. a new window pops up with ugly looks. i have also called a css file in printer friendly page but when i examine it in IE8 developer tool it shows me just css properties applied on body and fieldset. rest of properties are not there.
suggestions and help are highly appreciated
thanks

+2  A: 

the div tag was left open in the following code line

docprint.document.write('</head><body><fieldset style="border:none;"><div class="memo-report-top"');

closing it resolved the problem thanks everyone for ur input
regrds
adeel

Muhammad Adeel Zahid