Search code examples
javascriptprintingfancybox

javascript:window.print() not working with fancybox


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?


Solution

  • 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>