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

  • SEARCH
  • Home
  • 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 9133547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:30:26+00:00 2026-06-17T08:30:26+00:00

I have a JS function which prints the contents of a particular div called

  • 0

I have a JS function which prints the contents of a particular div called divDisplay of my html page ( the half bottom part of the page ), when someone clicks a button. The contents of this div are received dynamically ( ajax ) when the user interacts with the page. Printing works perfectly in FF,OPERA,IE but the data is scrambled, without color and out of the correct position ( as if there is no css formatting ) in chrome and safari in the pop up window to be printed.

function jsPrintDiv(m) {

    glblPopupWindow = window.open("", "PrintWindow", "width=1024,height=768,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes");
    glblPopupWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><link rel="stylesheet" type="text/css" href="styles.css"></head><body><div name="divDisplay" id="divDisplay">' + document.getElementById(m).innerHTML + '</div></body></html>');
    glblPopupWindow.document.close();
    glblPopupWindow.document.getElementById("divDisplay").style.top = "0px";

    glblPopupWindow.focus();
    glblPopupWindow.print();
    glblPopupWindow.close();

}

styles.css is the same css file that the original html page where the printing is taking place has. the same goes for the doctype.

the css of divDisplay:

#divDisplay {
    position: absolute;
    left: 0.2%;
    top: 305px;
    width: 99.6%;
    bottom: 0.5%;
    /* height: expression(document.body.offsetHeight - 314 + "px"); */
    overflow: auto;
    background-color: #AACCFF;
    font-family: palatino linotype;
    font: palatino linotype;

    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
}

Any ideas what i may be doing wrong? thanks in advance!

EDIT:

correct data in pop window to be printed ( firefox ):
http://img208.imageshack.us/img208/8195/ffprint.jpg

scrambled data in pop window to be printed ( chrome ):
http://img152.imageshack.us/img152/6108/chprint.jpg

EDIT2:
if i comment out the

glblPopupWindow.print();

line, chrome displays it correctly. dunno if that helps.

  • 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-06-17T08:30:27+00:00Added an answer on June 17, 2026 at 8:30 am

    The firefox window that you show, isn’t the print preview from firefox. The screen shot is the actual pop-up window, that’s why it looks correct. If you were to open the page in firefox, and go to ‘file’-> ‘print preview’ I bet it would look very similar to what you are seeing in Chrome.

    When you print a web page it won’t always look the same as it does when you view it. You can add a print style sheet for the page that should be printed, or you can add the print styling to an existing sheet. In your CSS specify styles for printing:

    @media print {
        /* Your Styles Here */
    }
    

    Also, browsers can interpret printing web pages differently. Defining good css for printing a site is a real pain. Good luck.

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

Sidebar

Related Questions

So I have this code which is called in a print_info() function after a
hi i have function which is called by tinker listbox so i cannot return
I have a function called viewDoc which is supposed to go to a folder
I have a function which echoes javascript to navigate to a different page. While
I have a foreach function which permits me to print fields in a database,
I have a pointer which points to a function. I would like to: if
Say I have a decorator which causes the function to print out any exceptions
Can I´m asking for advice. I have function which should return javascript object function
I have a function which looks something like this, it returns a noncopyable class
I have a function which I have to loop it a few times but

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.