Printing from an iframe in modal window in IE 7

by Andy 5/16/2008 10:13:00 AM
Printing of foupon in Iframe

I recently started loading our printable foupons into an embedded iframe which was displayed using a modal window (light box style)

Something I didn't realize when I started doing this is that IE 7's new shrink to fit printing caused the contents of my iframe to shrink down according to width of the iframe in its container.

To get around this I created a seperate style sheet containing

@media print
{

*
{
     display:none !important;
}

.fouponPopup
{
     display:block !important;
     width:100% !important;
     position:absolute !important;
     left:0px !important;
     top:0px !important;
}

.fouponPopup iframe
{
     display:block !important;
     width:100% !important;
}

}

Then in JS before showing the modal window (using AjaxControlToolKit) I add the style sheet to the header

fileref = document.createElement("link");
fileref.setAttribute(
"rel", "stylesheet");
fileref.setAttribute(
"type", "text/css");
fileref.setAttribute(
"href", website + "styles/print.css");
document.getElementsByTagName(
"head")[0].appendChild(fileref);

with fileref being a global variable.  Then when the user hits the close botton I remove the fileref object from the head.

document.getElementsByTagName("head")[0].removeChild(fileref);

I had to dynamically add/remove the css file so that users could print the pages normally in all other cases.

I am not 100% this is the best option to get around this issue in IE 7.  But it works.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , ,

Developement

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

1/6/2009 5:22:54 AM

©2008 Foupons LLC
www.foupons.com

Welcome to Foupons Press

Let us know what you think!

E-mail US Send mail

Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

Pages

    Recent posts

    Recent comments

    • Back on Track (1)
      Frank Smith wrote: That is crazy! I love the site keep up the great … [More]

    Archive

    Disclaimer

    Any comments made are those of our readers and do not represent foupons.com view in anyway.

    © Copyright 2009

    Sign in