By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,246 Members | 1,515 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,246 IT Pros & Developers. It's quick & easy.

Printing Iframe content

P: n/a
I am creating a web page that will contain multiple Iframes. One of
the Iframes will contain a bill of sale that is generated by a script
on x.mydomain.com/somefile.php?someparameters. One of the Iframes will
contain a PDF of a multiple page scanned document (this iframe can be
printed via the acrobat reader print button). The other iframes will
contain a jpeg of a scanned document which comes from
y.mydomain.com/somelocation/file.jpg.

The first iframe containing the bill of sale and each iframe containing
a jpeg could need to be printed. I will need to add a button on the
parent page (not within the iframe) to the bill of sale and each jpeg
iframe there after. This way the user can choose which documents to
print.

I have a function on the order of:

function (framename)
{
framename.focus();
framename.print();
}

then i make a button for each iframe, each iframe has a different name.

On my local development client I can get the bill of sale to print
(which is on the same x.domain.com as this multiple iframe script is
on) When I goto print the jpegs (on y.mydomain.com) I get an access
denied.
Is there an easy way of doing this. Any help appreciated.

Oct 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Right, the crossdomains issue, there's no access, lest print() method, to
other than local/caller domain due to security, if you can do away with the
frames altogether, do so and instead use Divs and have the server language
instead, fetch the data from the other domain and paste it in the page for
the client, so all fall within the same domain and the access is granted
for js. Can't use XMLHttpRequest either, it can only make requests to the
same server, so, the solution is to remove the crossdomain objects in
frames and have the server language instead, fetch them and then serve
them.
Danny
Oct 21 '05 #2

P: n/a
ni*******@gmail.com wrote:
I am creating a web page that will contain multiple Iframes. One of
the Iframes will contain a bill of sale that is generated by a script
on x.mydomain.com/somefile.php?someparameters. One of the Iframes will
contain a PDF of a multiple page scanned document (this iframe can be
printed via the acrobat reader print button). The other iframes will
contain a jpeg of a scanned document which comes from
y.mydomain.com/somelocation/file.jpg.

The first iframe containing the bill of sale and each iframe containing
a jpeg could need to be printed. I will need to add a button on the
parent page (not within the iframe) to the bill of sale and each jpeg
iframe there after. This way the user can choose which documents to
print.

I have a function on the order of:

function (framename)
{
framename.focus();
framename.print();
}

then i make a button for each iframe, each iframe has a different name.

On my local development client I can get the bill of sale to print
(which is on the same x.domain.com as this multiple iframe script is
on) When I goto print the jpegs (on y.mydomain.com) I get an access
denied.
Is there an easy way of doing this. Any help appreciated.


The advice provided by FAQ #19 seems appropriate. Browser security
stops you from accessing anything in a window from another domain, not
even the src attribute of the iframe that it's displayed in.

Best to collate the pages on your server and serve them from there.

You could put an object in your page that has frameName:url pairs so you
can get the URL from there then open a new window loaded with the 'other
domain' URL. But you can't remotely print it[1], the user would have to
print it (say press ctrl+p) for the same cross-domain reason noted above.

From the FAQ:

<URL:http://msdn.microsoft.com/workshop/author/om/xframe_scripting_security.asp>
[1] Calling window.print() on a child window with a page loaded from
another domain seems problematic in the browsers I tested - it works
sometimes on some browsers but not most of the time for others. Its
unreliability makes it unsuitable for a corporate Intranet or general
web environment.

--
Rob
Oct 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.