jQWidgets Forums
jQuery UI Widgets › Forums › Dialogs and Notifications › Window › Printing content of window
This topic contains 4 replies, has 2 voices, and was last updated by sjkcwatson 9 years, 10 months ago.
-
Author
-
Is there a way to print the content of a window? Or another approach that would work – frame, etc? Just need to print the html formmatted content. Thanks!
Or the content of one tab?
Hello sjkcwatson,
Unfortunately, exporting from jqxWindow is not available. You may try the following example as a workaround which exports window’s content in file: http://jsfiddle.net/9fjLah0p/.
Best Regards,
NadezhdajQWidgets team
http://www.jqwidgets.com/Hi sjkcwatson,
Here is another example which shows how to get the Windows’s HTML, add it to a new browser window and trigger printing.
<!DOCTYPE html> <html lang="en"> <head> <title></title> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxwindow.js"></script> </head> <body> <div id='content'> <script type="text/javascript"> $(document).ready(function () { $("#jqxwindow").jqxWindow({ height: 100, width: 300, }); $("#print").jqxButton(); $("#print").click(function () { var content = $('#jqxwindow').jqxWindow('content'); var newWindow = window.open('', '', 'width=300, height=100'), document = newWindow.document.open(), pageContent = '<!DOCTYPE html>\n' + '<html>\n' + '<head>\n' + '<meta charset="utf-8" />\n' + '<title>jQWidgets Window</title>\n' + '</head>\n' + '<body>\n' + content + '\n</body>\n</html>'; document.write(content); document.close(); newWindow.print(); }); }); </script> <div id='jqxwindow'> <div>Header</div> <div>Content</div> </div> <div style='margin-left: 10px; float: left;'> <input type="button" value="Print" id='print' /> </div> </div> </body> </html>
Best Regards,
NadezhdajQWidgets team
http://www.jqwidgets.com/Thank you – I appreciate the help and will try it.
-
AuthorPosts
You must be logged in to reply to this topic.