Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 930941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:25:13+00:00 2026-05-15T20:25:13+00:00

I am using colorbox to AJAX some external HTML onto a page. My client

  • 0

I am using colorbox to AJAX some external HTML onto a page.

My client wants to print this content direct from the page, therefore i used a print CSS loaded into the head of the document with colorbox’s onComplete event hook.

The content that is loaded is a raft of legacy tables with inline styles which i can’t seem to overwrite with the print CSS and when i view by media type the layout looks broken.

I put this down to only retrieving a chunk of the HTML with jQuery .find() rather than the whole page.

Would it be best to use an iframe with colorbox and load the whole HTML document including header. I assume this would preserve the layout better rather than retrieving a chunk.

I am not sure how to print the iframe’s content. When i tried it printed an extremely small snapshot of the whole page with the iframe in the middle.

Am a bit lost on this one.

The jQuery i am using is as follows:

$('table.pricing > tbody > tr > th > p.price_report > a').colorbox({
    title: "Price report",
    transition: "elastic",
    innerWidth: "733px",
    innerHeight: "699px",
    opacity: "0.5",
    onComplete:function(){
    // Ajax call to content
    // insert Print CSS into head of document 

    }

});

The print CSS that is loaded merely hides the body content and then displays everything under #colorbox.

Apologies all the proper code is at work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:25:14+00:00Added an answer on May 15, 2026 at 8:25 pm

    1) I would suggest switching to the “inline” colorbox option (but you don’t have to):

    <script type="text/javascript">
    $(document).ready(function(){
     $(".pricing").colorbox({width:"733px", height:"699px", iframe:false, open:true, overlayClose:true, opacity:.5, initialWidth:"300px", initialHeight:"100px", transition:"elastic", speed:350, close:"Close", photo:false, inline:true,  href:"#price_report"});
    });
    </script>
    

    2) Now add your html including the javascript and code to write your printable area:

    <div style='display: none'>
      <div id='price_report' class='pricing'>
    
    
    
    <script type="text/javascript">
    //<!--
    
    function ClickHereToPrint(){
        try{ 
            var oIframe = document.getElementById('ifrmPrint');
            var oContent = document.getElementById('pricingPrintArea').innerHTML;
            var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
            if (oDoc.document) oDoc = oDoc.document;
            oDoc.write("<html><head><title>My Printable Pricing Report!</title>");
            oDoc.write("<link rel='stylesheet' href='link-to-my-styles/style.css' type='text/css' />");
            oDoc.write("</head></body><body onload='this.focus(); this.print();' style='text-align: left; font-size: 8pt; width: 432pt;'>");
            oDoc.write("<h3>My Pricing Report</h3>");
            oDoc.write(oContent + "</body></html>");        
            oDoc.close();       
        }
        catch(e){
            self.print();
        }
    }
    
    //-->
    </script>
    
    
    
    
    <iframe id='ifrmPrint' src='#' style="width:0pt; height:0pt; border: none;"></iframe>
    
    <div id="pricingPrintArea">
    
       <div class="myreport">
           <p>Hello, I am a pricing report!</p>
       </div>
    </div>
    
    
    </div>
    </div>
    

    3) Now add the print button wherever you wish:

    <div id="print_btn">
    <a href="#" onclick="ClickHereToPrint();" style="cursor: pointer;">
    <span class="print_btn">
        Click Here To Print This Report!
    </span>
    </a>
    </div>  
    

    Note, the blank iframe included is where the javascript will write your printable area. You will also notice in the javascript that you can add a stylesheet, inline styles, a page title and more!

    Keep in mind, this process will work similar for the ajax version of the colorbox, but if you go the route of the ajax method, you will have to write the printable div and print iframe and print javascript directly to that external file.

    Theoretically, anything inside the printable region div (in this example: pricingPrintArea) will print, so as-long-as you wrap that around whatever you want to print, it will do so.

    Important tip: Printers all read a Web page differently so try not to rely too much on inline styles and pixel dimensions for your printable version. That is why it is a good idea to create a stylesheet specifically for the printable page.

    Hopefully that answers your question. (btw, you should be able to get this method to work with the ajax method of colorbox, but I haven’t tested it).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Colorbox to load some content from an external (but local) file.
I'm using Colorbox to show the html content of hidden divs on my page.
I'm using a jQuery plugin called Colorbox (http://colorpowered.com/colorbox/) and loading content via Ajax. This
I'm using the Colorbox lightbox plugin to display lightboxes with Outside HTML (Ajax) on
I have a website that uses ajax jquery and colorbox. Inside the div #content
I am using AJAX to dynamically update a page with a data table. When
I am using a jquery plugin called colorbox, this might be irrelevent though as
i am using jQuery colorbox plugin. it is true with asp.net page but not
for this I am using colorbox jQuery plugin http://colorpowered.com/colorbox/ and a form. I am
I am attempting to pull some information from my tnsnames file using regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.