Printing DHTML (CSS) in Netscape 4.0+

Printing DHTML (CSS) in Netscape 4.0+

I’ve put together an intranet site that uses JavaScript functions that put together a page. For example, the header section, body section, footer section, sidebar, and so on are called JavaScript functions. The sidebar and main body functions are displayed as DHTML style sheets. I need the content in the body or the whole page to print. Either will do. The problem is that it prints okay in Internet Explorer but when I try to print it in Netscape I get the error message, “There are no pages to print.” Also I don’t get side scroll bars in Netscape. Unfortunately, my client is a Netscape company. Can you help me?

The problem that you’re running into comes from the ways that the two browsers maintain information about their current state. In Internet Explorer, the browser actually manipulates the internal document whenever a change is made, which is part of the reason that you can set the innerHTML of any entity within the page and still have it appear in print. With the Netscape browser, on the other hand, the system only maintains the initial state of the document, and any modifications made are changes to the output, not the document. In other words, if I set the contents of a layer once the document has been displayed, I only change the display?the document remains static.

One upshot of this situation comes with printing. If you print out a document from Internet Explorer, the internal print engine traverses the current document’s representation and reformats it to fit page specifications. Thus, if you use .innerHTML, the new value will get output. With Netscape, only the original HTML is available for reformatting to the printer, not any changes made since then by JavaScript.

The solution, unfortunately, isn’t a pretty one. In order to output a modified page to the printer, you need to create the same document in HTML. Luckily it sounds like you’ve already done most of the precursor work for this task yourself. First you need to create a buffer of HTML output that mirrors the document currently in memory. Then you open a new window and pump the contents of the new pseudo-page into the window as a separate document. In general, it’s best to separate the accumulation of the text (or the building of the page) from the mechanics of opening the window and displaying the contents.

As I said, it’s not a terribly elegant solution, but until Netscape formally adopts the W3C HTML Object model sometime later this year with Netscape 5, it’s about the only option that’s available.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several