Skip to main content

Access Iframe of Dcontainer for printing

3 replies [Last post]
hmistry
Offline
Joined: 2008-08-04
Points: 0

I have a dcontainer and i need to print the content.
when i use an iframe i use
window.frames['iframe1'].focus();
window.frames['iframe1'].print();
Where iframe1 is the id of the iframe

can something similar be done for dcontainer

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gmurray71
Offline
Joined: 2003-07-31
Points: 0

Hi hmistry,

The naming convention for the dcontainers is:

${id}_${viewid}_iframe

So if you have a single dcontainer with the id attribute as 'foo' the id will be:

foo_default_iframe

'default' is the view for a single view dcontainer.

if you have a dcontainer with multiple views like:

<div jmakiId="foo" jmakiName="jmaki.dcontainer" jmakiValue="{ items : [ { id : 'bar', iframe : true}, {id : 'bar2', iframe : true}]}"></div>

The first iframe would have the id:

foo_bar_iframe

and the second

foo_bar_iframe

You can get a handle on the elements using:

var frame = document.getElementById('foo_default_iframe');
frame.focus();
frame.print();

Let me know if that doesn't work.

hmistry
Offline
Joined: 2008-08-04
Points: 0

Hi Greg

Gr8 many thanks

I am using a dcontainer with single view so 'dContainer_default_iframe' is correct for my case

But the code below as suggested by you sets the focus but does not print

var frame = document.getElementById('dContainer_default_iframe');

frame.focus();

frame.print();




But i used

window.frames['dContainer_default_iframe'].focus();

window.frames['dContainer_default_iframe'].print();




And it worked fine. At present i have Internet explore 7. will this work for other browsers like firefox and opera too.

hmistry
Offline
Joined: 2008-08-04
Points: 0

I tried it on firefox and it works like a charm many thanks for showing the way