We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Print the content of another frame in the frameset

Medium Priority
946 Views
Last Modified: 2013-11-19
Hello,

I have a frameset which contains 2 frames: the upper frame has a "Print" button and the lower frame contains data.
I have tries to print the data in the lower frame when pressing the button in the upper frame by using:

parent[1].focus();
parent[1].print();

but i get an "access denied" problem. Both frames are in the same domain...

How can i print the content of the lower frame?

Thanks,
Dana
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2004

Commented:
shouldn't:

    parent[1].print();

be

    parent.frames[1].print();

?

Author

Commented:
No, i still get "Access Denied"
CERTIFIED EXPERT
Top Expert 2004

Commented:
Do your frames have names?

Author

Commented:
yes
CERTIFIED EXPERT
Top Expert 2004

Commented:
you could try

    parent[ 'frameName' ].focus();
    parent[ 'frameName' ].print();

or

    parent.frameName.focus() ;
    parent.frameName.print() ;

Otherwise, I'm stumped :-/

Author

Commented:
Working with frames' names doesn't work either. i still get "Access Denied"
CERTIFIED EXPERT
Top Expert 2004

Commented:
Can you post the FRAMESET definition?

Author

Commented:
still the same........... :-(

Author

Commented:
This is the FRAMESET definition:

<frameset rows="41,*" border=0 framespacing=0 frameborder=0>
      <frame name="viewerHeader" id="viewerHeader" src="viewerN.aspx" scrolling="no" noresize>
      <frameset cols="100%,0" id=lower border=0 framespacing=0 frameborder=0>
            <frame name="viewerBodyNew" id="viewerBodyNew" src="viewerBody.aspx" scrolling="auto" noresize>
            <frame name="viewerSummary" id="viewerSummary" src="Summary.aspx" scrolling="auto" noresize>
      </frameset>
</frameset>

Commented:
can I see the page?

Author

Commented:
no, sorry :-(
It is internal..

But, the upper frame contains the next code:

<td align="right" valign="top" style="LEFT: 570px; POSITION: absolute; TOP: 0px">
      <a href="javascript:Print()"><img src="images/btn_email.gif" title="Print" border="0"></a>
</td>

and the javascript function:

function Print(what)
{
      parent[ 'viewerBodyNew' ].focus();
      parent[ 'viewerBodyNew' ].print();
}

CERTIFIED EXPERT
Top Expert 2004

Commented:
Try changing:

      <a href="javascript:Print()"><img src="images/btn_email.gif" title="Print" border="0"></a>

to:

      <a href="#" onclick="doPrinting(); return false"><img src="images/btn_email.gif" title="Print" border="0"></a>

and

function Print(what)
{
     parent[ 'viewerBodyNew' ].focus();
     parent[ 'viewerBodyNew' ].print();
}

to

function doPrinting()
{
     parent[ 'viewerBodyNew' ].focus();
     parent[ 'viewerBodyNew' ].print();
}

Author

Commented:
Still the same... "Access Denied"
CERTIFIED EXPERT
Top Expert 2004

Commented:
Right...last try...  can you try changing:

function doPrinting()
{
     parent[ 'viewerBodyNew' ].focus();
     parent[ 'viewerBodyNew' ].print();
}

to:

function doPrinting()
{
     top.viewerBodyNew.focus();
     top.viewerBodyNew.print();
}

?

Otherwise I'm stumped as to why this is happening :-(

Tim
Make sure no any redirect script on your page. And the sites is not in the Restricted Sites zone.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
You will get "Access Denied" as long as you get Cross Domain Access violation.
To find why you get Cross Domain Access condition at all check for this aspects:
1.) Are both frame URLs from same Internet domain?
2.) Is one frame URL without Internet domain suffix (only machine name)?
3.) Is one or both URLs nummeric instead sybolic names?
4.) Are both URLs same protocol (http/https)?
5.) Is one URL different port suffix, lik :8080

Author

Commented:
There is a redirect which is done in the lower frame 'viewerBodyNew' to another domain.

I get a URL in the lower frame and change the location of the frame to that URL:

document.location.href = theURL

In case this is the problem, is there a way to work around this?

Thanks,
Dana
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
No, there is NO way around the cross domain access protection.
If redirect to outside sites, then is different domain too.

I view you use aspx, you can capture the outside sites html souce on server-side and become to your page under your domain.
CERTIFIED EXPERT
Top Expert 2004
Commented:
>> you can capture the outside sites html souce on server-side and become to your page under your domain.

It depends how the page has been coded...  relative links to images/files/other URLS will give you a nightmare :-(

Tim
Yes. If is sumbersome coding for files !!~
 If image file you can create a page and try to use <IMG SRC=""> to show the image, the security will not check this.

Author

Commented:
Thanks for all the answers,

We have given up the print function for now....
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.