Note that there are some explanatory texts on larger screens.

plurals
  1. POscrambled data when printing in google chrome and safari through javascript
    primarykey
    data
    text
    <p>I have a JS function which prints the contents of a particular div called <strong>divDisplay</strong> of my html page ( the half bottom part of the page ), when someone clicks a button. The contents of this div are received dynamically ( ajax ) when the user interacts with the page. Printing works perfectly in FF,OPERA,IE but the data is scrambled, without color and out of the correct position ( as if there is no css formatting ) in chrome and safari in the pop up window to be printed.</p> <pre><code>function jsPrintDiv(m) { glblPopupWindow = window.open("", "PrintWindow", "width=1024,height=768,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes"); glblPopupWindow.document.write('&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;&lt;html&gt;&lt;head&gt;&lt;link rel="stylesheet" type="text/css" href="styles.css"&gt;&lt;/head&gt;&lt;body&gt;&lt;div name="divDisplay" id="divDisplay"&gt;' + document.getElementById(m).innerHTML + '&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;'); glblPopupWindow.document.close(); glblPopupWindow.document.getElementById("divDisplay").style.top = "0px"; glblPopupWindow.focus(); glblPopupWindow.print(); glblPopupWindow.close(); } </code></pre> <p><strong>styles.css</strong> is the same css file that the original html page where the printing is taking place has. the same goes for the <strong>doctype</strong>.</p> <p>the css of <strong>divDisplay</strong>:</p> <pre><code>#divDisplay { position: absolute; left: 0.2%; top: 305px; width: 99.6%; bottom: 0.5%; /* height: expression(document.body.offsetHeight - 314 + "px"); */ overflow: auto; background-color: #AACCFF; font-family: palatino linotype; font: palatino linotype; -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; } </code></pre> <p>Any ideas what i may be doing wrong? thanks in advance!</p> <p><strong>EDIT:</strong></p> <p>correct data in pop window to be printed ( firefox ): <a href="http://img208.imageshack.us/img208/8195/ffprint.jpg" rel="nofollow">http://img208.imageshack.us/img208/8195/ffprint.jpg</a></p> <p>scrambled data in pop window to be printed ( chrome ): <a href="http://img152.imageshack.us/img152/6108/chprint.jpg" rel="nofollow">http://img152.imageshack.us/img152/6108/chprint.jpg</a></p> <p><strong>EDIT2:</strong> if i comment out the</p> <pre><code>glblPopupWindow.print(); </code></pre> <p>line, chrome displays it correctly. dunno if that helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload