printing an iFrame

  • JiRaffe
  • Newbie
  • Newbie
  • User avatar
  • Posts: 13
  • Loc: Liverpool

Post 3+ Months Ago

i have an iFrame sat in the middle of a page and i was wondering if there is a way to set it so that when a user clicks on their normal 'Print' button on the file menu, it prints just the content of the iFrame.

This code is usually applied to a "printer-friendly" button...

function myprint() {
window.parent.FRAMENAME.focus();
window.print();
}

but i was wondering if you could apply it in the manner described above.

cheers
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

If I'm reading this right, you can do this with CSS. In your style sheet you can define two sections, one for display on the computer, one for printing, like so:
Code: [ Select ]
@media screen {
IFRAME{height:200px;width:400px;}
}

@media print{
IFRAME{height:100%;width:100%;}
}
  1. @media screen {
  2. IFRAME{height:200px;width:400px;}
  3. }
  4. @media print{
  5. IFRAME{height:100%;width:100%;}
  6. }


In the 'print' section, you can define it so nothing else on the (web)page prints.

To be honest, I have implemented "print" styles, but I've never really collected any data on their success. It's always worked well for me. I'm sure I've never tried to do this thing with the iframe, specifically, though.

Any of this make sense?

btw: I just pointed out in another thread that you can use a DIV as a scrollable area. Perhaps this would be a good solution for you. (?)
http://www.domedia.org/oveklykken/css-div-scroll.php
http://www.siteexperts.com/dhtmllib/dem ... /page2.asp
  • JiRaffe
  • Newbie
  • Newbie
  • User avatar
  • Posts: 13
  • Loc: Liverpool

Post 3+ Months Ago

cheers for that. for some reason i never realised you could control an iframes attributes through css.

BUT... unfortunately i still can't get it to work because it seems that printers will not accept iFrames which are any longer than 1 page. which is a pain to say the least.

and i cannot use a scrolling Div because my content needs to have anchor links, which do not work in scrolling Divs.

so that points me back in the direction of targeting the frame and then printing its contents.

thanks for the suggestions
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

Really?!?

The example below works fine for all my browsers, with one exception - Opera doesn't do the in-page link.

Code: [ Select ]
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style>
body{background:#C30;}
#idea{width:200px;height:200px;overflow:auto;background:#FFF;padding:15px;}
a{color:#C30;}
</style>
</head>

<body>
<div id="idea">
<a href="#test">Link to an anchor NAME attribute</a>, <a href="http://www.ozzu.com/" target="new">Link to Ozzu.</a> sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exercitation ulliam corper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem veleum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel willum lunombro dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

Li Europan lingues es membres del sam familie. Lor separat existentie es un myth. Por scientie, musica, sport etc., li tot Europa usa li sam vocabularium. Li lingues differe solmen in li grammatica, li pronunciation e li plu commun vocabules. Omnicos directe al desirabilit√° de un nov lingua franca: on refusa continuar payar <a name="test">HERE</a> custosi traductores. It solmen va esser necessi far uniform grammatica, pronunciation e plu sommun paroles.

Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental: in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es.</div>
</body>
</html>
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>Untitled Document</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  7. <style>
  8. body{background:#C30;}
  9. #idea{width:200px;height:200px;overflow:auto;background:#FFF;padding:15px;}
  10. a{color:#C30;}
  11. </style>
  12. </head>
  13. <body>
  14. <div id="idea">
  15. <a href="#test">Link to an anchor NAME attribute</a>, <a href="http://www.ozzu.com/" target="new">Link to Ozzu.</a> sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exercitation ulliam corper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem veleum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel willum lunombro dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
  16. Li Europan lingues es membres del sam familie. Lor separat existentie es un myth. Por scientie, musica, sport etc., li tot Europa usa li sam vocabularium. Li lingues differe solmen in li grammatica, li pronunciation e li plu commun vocabules. Omnicos directe al desirabilit√° de un nov lingua franca: on refusa continuar payar <a name="test">HERE</a> custosi traductores. It solmen va esser necessi far uniform grammatica, pronunciation e plu sommun paroles.
  17. Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental: in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es.</div>
  18. </body>
  19. </html>


Maybe you're doing something different, though. Perhaps you mean that you need to navigate between pages within that space. In which case you could swap the contents of the DIV with some scripting. That would make for a VERY indexable page. All your keywords in one HTML file would rock.
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

In further trial, I was able to put images in the scrolling area, and havve them linked as well. This worked in all browsers for me.
  • JiRaffe
  • Newbie
  • Newbie
  • User avatar
  • Posts: 13
  • Loc: Liverpool

Post 3+ Months Ago

it doesn't work in IE/mac, Safari or Opera. That would be too much of a problem except that in IE on the mac it actually totally screws up the page, which is a real pain
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

ahhh. I didn't do any MAC testing.

Cheers!!
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

Ok, I just had this tested on OS X.3.3 and it worked fine for IE-MAC, Camino, and Safari. Just an FYI.

(I really want to make this work. I plan on implementing it for a client. heh.)
  • JiRaffe
  • Newbie
  • Newbie
  • User avatar
  • Posts: 13
  • Loc: Liverpool

Post 3+ Months Ago

not sure why it worked for you. on my mac (os x.3) in safari it does nowt and in IE it jumps down the parent page to where the achor link would be if the DIV was not scroll (if you understand that). it's exactly the problem i was having in mine. apparently there isn't really a resolution.
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

Oh, yes. I had the same result with the in-page link in IE-Mac. I don't plan on using any in-page links in mine, though. Even I was, I'd have to draw the line somewhere.

;)

Sorry, though. I thought you meant it wasn't displaying correctly, at all.
  • JiRaffe
  • Newbie
  • Newbie
  • User avatar
  • Posts: 13
  • Loc: Liverpool

Post 3+ Months Ago

ahhh, no it displays fine, my only stumbling block was the in-page links

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 61 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.