0

I have an html page (let's call parent) with a link that opens another html page (call this child) in fancybox. Inside the child html, I have this anchor

<a href="javascript:window.print();" style="color:#663300;">Imprimir</a><br />

The problem is, this prints the the parent AND the child page. Is this the typical fancybox behaviour? How do I print only the child?

Martijn
  • 15,791
  • 4
  • 36
  • 68
Alex Angelico
  • 3,710
  • 8
  • 31
  • 49
  • the div u want to print is #fancybox-content check out this thread http://stackoverflow.com/questions/468881/print-div-id-printarea-div-only – Johnny Craig Aug 26 '11 at 22:28

2 Answers2

2

I edit from code on other threads... this should work

<style type="text/css">
    @media print
    {
        body * { visibility: hidden; }
        #fancybox-content * { visibility: visible; }
        #fancybox-content { position: absolute; top: 1px; left: 1px; }
    }
</style>
Johnny Craig
  • 4,974
  • 2
  • 26
  • 27
  • thanks, I used this css: * { margin: 0; padding: 0; } body * { visibility: hidden; } #fancybox-content * { visibility: visible; } #fancybox-content { position: absolute; top: 0; left: 0; } body, html, div, #fancybox-content { background: #FFF !important; } – Ruben Mar 01 '12 at 14:38
0

yes. The js command you're calling is window.print(). What you need to do is only print the container of the fancybox. A quick google search came up with a bunch of links on how to do this. Here's one:

Print <div id=printarea></div> only?

Community
  • 1
  • 1
SBerg413
  • 14,515
  • 6
  • 62
  • 88