gm3h Posted November 15, 2011 Share Posted November 15, 2011 Can somebody tell me how to print the content of TUniURLFrame ? I've used window.print() in the onClick() event of ClientEvents.ExtEvents, but it print the whole webpage of course. I've tried Form1.urlFrame1.print(), also nothing happen. Also, if possible, is there any way I can just print directly to printer without the Print Dialog ?? Quote Link to comment Share on other sites More sharing options...
andersa@ellenshoej.dk Posted November 15, 2011 Share Posted November 15, 2011 I found this code on the netz maybe it will work: <script type="text/javascript"> function zPrint(oTgt) { oTgt.focus(); oTgt.print(); } </script> . . . <body> <iframe name="myFrame" id="myFrame" width="600" height="400" src="about:mozilla></iframe> <input type="button" value="Print IFRAME" onclick="zPrint(myFrame);" /> </body> URLFrames are iframes, so maybe you can modify the idea used here somehow. I am no expert in javascript, so I can't really say if it will work or not. Quote Link to comment Share on other sites More sharing options...
gm3h Posted November 16, 2011 Author Share Posted November 16, 2011 I found this code on the netz maybe it will work: <script type="text/javascript"> function zPrint(oTgt) { oTgt.focus(); oTgt.print(); } </script> . . . <body> <iframe name="myFrame" id="myFrame" width="600" height="400" src="about:mozilla></iframe> <input type="button" value="Print IFRAME" onclick="zPrint(myFrame);" /> </body> URLFrames are iframes, so maybe you can modify the idea used here somehow. I am no expert in javascript, so I can't really say if it will work or not. thank you for your reply. But, I don't know what the id of URLFrame after uniGUI compiled the code into javascript. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted November 16, 2011 Administrators Share Posted November 16, 2011 Id of UrlFrame is defined as: "iframe_"+ComponentName for exampe: "iframe_UniURLFrame1" Quote Link to comment Share on other sites More sharing options...
gm3h Posted November 17, 2011 Author Share Posted November 17, 2011 Id of UrlFrame is defined as: "iframe_"+ComponentName for exampe: "iframe_UniURLFrame1" Thank you Farshad and Anders.. Now it works. Here's what I do. 1. in the Form1.Script i put: function zPrint(oTgt) { oTgt.focus(); oTgt.print(); } 2. in the button.ExtEvents.OnClick() i put: zPrint(iframe_UniURLFrame1); /* without the quotation mark */ Now, how about print dialog? I don't want to show the print dialog, just directly print to the default printer. Quote Link to comment Share on other sites More sharing options...
andersa@ellenshoej.dk Posted November 17, 2011 Share Posted November 17, 2011 Now, how about print dialog? I don't want to show the print dialog, just directly print to the default printer. http://javascript.about.com/od/events/a/print.htm Quote Link to comment Share on other sites More sharing options...
bruno-pere Posted June 14, 2012 Share Posted June 14, 2012 Does not work for me. Can someone send a sample code? UniGUI is creating my iframe with name iframe_UniURL_020. Is it correct? I saw that in the HTML code. Thx! Bruno Quote Link to comment Share on other sites More sharing options...
bruno-pere Posted June 14, 2012 Share Posted June 14, 2012 Working now. zPrint function in the Form.Script. And this in the extevents of the button: function OnClick(sender, e) { var frm = document.getElementById("iframe_UniURL1_O20"); if (frm) { zPrint(frm.contentWindow); } } Why is the "_O20" added to the end of the iframe id? Will this change after some page reloadings? Bye! Bruno Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted June 15, 2012 Administrators Share Posted June 15, 2012 Working now. zPrint function in the Form.Script. And this in the extevents of the button: function OnClick(sender, e) { var frm = document.getElementById("iframe_UniURL1_O20"); if (frm) { zPrint(frm.contentWindow); } } Why is the "_O20" added to the end of the iframe id? Will this change after some page reloadings? Bye! Bruno In 0.89 use can use: var frm = MainForm.UniURLFrame1.iframe; Quote Link to comment Share on other sites More sharing options...
bruno-pere Posted June 15, 2012 Share Posted June 15, 2012 The code was not working in Firefox and Chrome. I did some changes and now it's working that browsers too. In the Form.Script: function zPrint(oTgt){ oTgt.focus(); oTgt.print(); } function printIframe(id) { var iframe = id; var ifWin = iframe.contentWindow || iframe; // the change zPrint(ifWin); return false; } In the button.ExtEvents.OnClick: function OnClick(sender, e) { var frm = UniFormShowLink.UniURL1.iframe; if (frm) { printIframe(frm); } } Bye! Bruno Quote Link to comment Share on other sites More sharing options...
alp.yilmaz Posted May 18, 2017 Share Posted May 18, 2017 In the Form.Script:function zPrint(oTgt){oTgt.focus();oTgt.print();}function printIframe(id){var iframe = id;var ifWin = iframe.contentWindow || iframe; // the changezPrint(ifWin);return false;}In the button.ExtEvents.OnClick:function OnClick(sender, e){var frm = UniFormShowLink.UniURL1.iframe;if (frm) {printIframe(frm);}} Bu Kodu Çalıştıramadım. UniURLFrame1 içerisindeki HTML Kodunu Print etmek istiyorum Yardımcı olursanız sevinirim. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.