Avatar of hrhs
hrhsFlag for United States of America

asked on 

Printing IFrames for Beginners (Updated)

I know there are a ton of questions here about printing IFrames.  I have gone through most of them and I am not getting them to work.  Many of them are from years ago and I afraid maybe they're outdated?

I am embedding a Google Doc (so cross-domain might be an issue) in a page and I am trying to find a cross browser solution that works to print the content of the IFrame.  I am somewhat new to javascript so I would need some help with the complete function syntax and the syntax for the html to call the function.  I've tried all kinds of things, nothing seems to work.  My IFrame id is "policy".

Thanks,

Dave
JavaScript.NET Programming

Avatar of undefined
Last Comment
COBOLdinosaur
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Cross-domain is the issue.  Modern browsers do not permit it because it was a huge security hole in the past that resulted in tens of thousands of sites hacked and millions of users infected with virus code.

You will not find a way to print the contents of the iframe from a main page no matter what you try.  It will always fail as a security violation.  Either the page in the frame must contain print functionality, or you can bring the page in without the frame and print using the browser or print screen.

Cd&
Avatar of hrhs
hrhs
Flag of United States of America image

ASKER

Would you know a print solution for embedded Google Docs?

I am attempting to formulate a solution for embedding hundreds of policy documents on an Intranet and I would have to have a print solution for posting the policies in paper form within department physical locations.
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Well if you are doing it for an intranet app.  Just save the complete pages on your server.  Then you can serve them from the same local domain and there is no longer any cross-domain issue.  

Or scrape the pages and save the text components in a database.  then you can generate the pages as needed for both viewing and printing.

Cd&
Avatar of hrhs
hrhs
Flag of United States of America image

ASKER

Well, the reason I want to keep them in Google Docs is to empower the document creators and collaborators to maintain their own documents as a team.
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo