Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Another solution</h2> <p>Here is a new solution based on <a href="https://stackoverflow.com/a/2618980/603003">Bennett McElwee answer</a> in the <a href="https://stackoverflow.com/users/24181/greg">same question</a> as mentioned below.</p> <p>Tested with IE 9 &amp; 10, Opera 12.01, Google Chrome 22 and Firefox 15.0. <br /> <a href="http://jsfiddle.net/95ezN/3/" rel="nofollow noreferrer">jsFiddle example</a></p> <h3>1.) Add this CSS to your site:</h3> <pre class="lang-css prettyprint-override"><code>@media screen { #printSection { display: none; } } @media print { body * { visibility:hidden; } #printSection, #printSection * { visibility:visible; } #printSection { position:absolute; left:0; top:0; } } </code></pre> <h3>2.) Add my JavaScript function</h3> <pre class="lang-js prettyprint-override"><code>function printElement(elem, append, delimiter) { var domClone = elem.cloneNode(true); var $printSection = document.getElementById("printSection"); if (!$printSection) { $printSection = document.createElement("div"); $printSection.id = "printSection"; document.body.appendChild($printSection); } if (append !== true) { $printSection.innerHTML = ""; } else if (append === true) { if (typeof (delimiter) === "string") { $printSection.innerHTML += delimiter; } else if (typeof (delimiter) === "object") { $printSection.appendChild(delimiter); } } $printSection.appendChild(domClone); }​ </code></pre> <p>You're ready to print any element on your site! <br /> Just call <code>printElement()</code> with your element(s) and execute <code>window.print()</code> when you're finished.</p> <p><strong>Note:</strong> If you want to modify the content before it is printed (and only in the print version), checkout this example (provided by waspina in the comments): <a href="http://jsfiddle.net/95ezN/121/" rel="nofollow noreferrer">http://jsfiddle.net/95ezN/121/</a></p> <p>One could also use CSS in order to show the additional content in the print version (and only there).</p> <hr /> <h2>Former solution</h2> <p>I think, you have to hide all other parts of the site via CSS.</p> <p>It would be the best, to move all non-printable content into a separate <code>DIV</code>:</p> <pre class="lang-html prettyprint-override"><code>&lt;body&gt; &lt;div class="non-printable"&gt; &lt;!-- ... --&gt; &lt;/div&gt; &lt;div class="printable"&gt; &lt;!-- Modal dialog comes here --&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>And then in your CSS:</p> <pre class="lang-css prettyprint-override"><code>.printable { display: none; } @media print { .non-printable { display: none; } .printable { display: block; } } </code></pre> <p>Credits go to <a href="https://stackoverflow.com/users/24181/greg">Greg</a> who has already answered a similar question: <a href="https://stackoverflow.com/questions/468881/print-div-id-printarea-div-only">Print &lt;div id=&quot;printarea&quot;&gt;&lt;/div&gt; only?</a></p> <p>There is <strong>one problem in using JavaScript</strong>: the user cannot see a preview - at least in Internet Explorer!</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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