Jump to content

Recommended Posts

Posted

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 ??

Posted

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.

Posted

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.

Posted

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.

  • 6 months later...
Posted

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

Posted

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

  • Administrators
Posted

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;

Posted

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

  • 4 years later...
Posted

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);
}
}

 

Bu Kodu Çalıştıramadım.

UniURLFrame1 içerisindeki HTML Kodunu Print etmek istiyorum

Yardımcı olursanız sevinirim.

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...