I canβt write the code for you right now, but I can put you on the right track.
You need to use jquery to get the content you want to print (most likely $('body').html(); ), then create your modal div popup and add an iframe to the modal div. Then add iframes (via $('iframe').document.body.append(); ) to the body of the print. Then call print on iframe ( $('iframe').window.print; )
Let me know if that makes sense?
EDIT . Here is an example of code that works with what I think you need. (make sure you include jquery before this javascript code)
<body> <script> $(document).ready(function(){ $('#printmodal').click(function(){ </script> <style> #modal { display: none; width: 100px; height: 100px; margin: 0 auto; position: relative; top: 100px; } </style> <div id="printable"> <p>This is</p> <p>printable</p> </div> <a id="printmodal" href="#">Print Me</a> <div id="modal"> <iframe id="printframe" /> </div> </body>
jsfiddle: http://jsfiddle.net/tsdexter/ke2rqt97/
source share