Print the content of another frame in the frameset

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
RelegenceAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimYatesCommented:
shouldn't:

    parent[1].print();

be

    parent.frames[1].print();

?
RelegenceAuthor Commented:
No, i still get "Access Denied"
TimYatesCommented:
Do your frames have names?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

RelegenceAuthor Commented:
yes
TimYatesCommented:
you could try

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

or

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

Otherwise, I'm stumped :-/
RelegenceAuthor Commented:
Working with frames' names doesn't work either. i still get "Access Denied"
TimYatesCommented:
Can you post the FRAMESET definition?
RelegenceAuthor Commented:
still the same........... :-(
RelegenceAuthor 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>
LakioCommented:
can I see the page?
RelegenceAuthor 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();
}

TimYatesCommented:
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();
}
RelegenceAuthor Commented:
Still the same... "Access Denied"
TimYatesCommented:
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
bubbledragonCommented:
Make sure no any redirect script on your page. And the sites is not in the Restricted Sites zone.
ZvonkoSystems architectCommented:
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

RelegenceAuthor 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 architectCommented:
No, there is NO way around the cross domain access protection.
bubbledragonCommented:
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.
TimYatesCommented:
>> 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bubbledragonCommented:
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.
RelegenceAuthor Commented:
Thanks for all the answers,

We have given up the print function for now....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.