473,396 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Expanding collapsed text when printing

Let me start by saying that I know very little about JavaScript.

The software that I use to convert my FrameMaker files to HTML uses a
JavaScript to hide certain text. The user has to click the paragraph to
display that text.

Currently, that collapsed text prints only if I go ahead and expand it
on my HTML page. I want to be able to have that text automatically
print, regardless of whether the user has expanded it on the HTML page.

I tried adding the following to my CSS file, but it didn't work.

=====
@media print {
div {display:block;visibility:visible;}
}
=====

I investigated a little farther, and found that the software that I'm
using doesn't use something like

<div id="1" style="display: none" onclick="doExpand(1,ar1)">

to hide the text. Instead, the code that it uses is similar to the
following:

<script type="text/javascript" language="JavaScript1.2">
WebWorks_WriteDIVOpen("wwdd1686284", false); </script>

Changing that "false" to "true" expands the text by default.

In the referenced JS file, I found the following code for this
function.

=====
function WebWorks_WriteDIVOpen(ParamID,
bParamExpanded)
{
if ((WWHFrame != null) &&
( ! WWHFrame.WWHHelp.mbAccessible) &&
((typeof(document.all) != "undefined") ||
(typeof(document.getElementById) != "undefined")))
{
if ((bParamExpanded) ||
((typeof(WWHFrame.WWHHighlightWords) != "undefined") &&
(WWHFrame.WWHHighlightWords != null) &&
(WWHFrame.WWHHighlightWords.mWords != null)))
{
document.write("<div id=\"" + ParamID + "\" style=\"visibility:
visible; display: block;\">");
}
else
{
document.write("<div id=\"" + ParamID + "\" style=\"visibility:
hidden; display: none;\">");
}
}
}
=====

Is there some code I can add somewhere to make this work?

(Let me know if I need to include more code to be helpful.)
====================
Rick Henkel
http://rickhenkel.ipdz.com

Sep 27 '06 #1
2 3011
On 2006-09-27 17:00:27 +0200, "Rick"
<ja*********************@spamgourmet.comsaid:
The software that I use to convert my FrameMaker files to HTML uses a
JavaScript to hide certain text. The user has to click the paragraph to
display that text.

Currently, that collapsed text prints only if I go ahead and expand it
on my HTML page. I want to be able to have that text automatically
print, regardless of whether the user has expanded it on the HTML page.

I tried adding the following to my CSS file, but it didn't work.

=====
@media print {
div {display:block;visibility:visible;}
}
=====

I investigated a little farther, and found that the software that I'm
using doesn't use something like

<div id="1" style="display: none" onclick="doExpand(1,ar1)">

to hide the text. Instead, the code that it uses is similar to the
following:

<script type="text/javascript" language="JavaScript1.2">
WebWorks_WriteDIVOpen("wwdd1686284", false); </script>

Changing that "false" to "true" expands the text by default.

In the referenced JS file, I found the following code for this
function.

=====
....
document.write("<div id=\"" + ParamID + "\" style=\"visibility:
visible; display: block;\">");
}
else
{
document.write("<div id=\"" + ParamID + "\" style=\"visibility:
hidden; display: none;\">");
....

What browser are you using ?
I seem to recall that IE considers any inline CSS rule more important
than rules defined in the stylesheet, so much so that a
stylesheet-defined property can never overrule the inline value (even
when it is more specific and !important).

So it may just work in W3C-compliant browsers, but inline CSS is ugly
anyway, and should be used lightly, so let's change that.

You could alter the script so that, instead of setting inline style
properties, it just sets a class name. For instance, replace the above
with this :

Expand|Select|Wrap|Line Numbers
  1. document.write("<div id=\"" + ParamID + "\">");
  2. }
  3. else
  4. {
  5. document.write("<div id=\"" + ParamID + "\" class=\"print_only\">");
  6.  
and in you CSS file :

Expand|Select|Wrap|Line Numbers
  1. @media screen {
  2. ..print_only {
  3. display: none;
  4. }}
  5.  
  6. @media print {
  7. .print_only {
  8. display: block;
  9. }}
  10.  
I placed both definitions in a @media rule for accessibility's sake.
Browsers that don't understand @media rules will ignore both, so they
will display the text on screen but at least they will also print it.
Of course you can extend the list of media that should or should not
display the text.

If you ever want to disable text hiding, just load a CSS file without
..print_only declarations, or remove these declarations dynamically.
--
David Junger

Sep 28 '06 #2
What browser are you using ?
I seem to recall that IE considers any inline CSS rule more important
than rules defined in the stylesheet, so much so that a
stylesheet-defined property can never overrule the inline value (even
when it is more specific and !important).

So it may just work in W3C-compliant browsers, but inline CSS is ugly
anyway, and should be used lightly, so let's change that.

You could alter the script so that, instead of setting inline style
properties, it just sets a class name. For instance, replace the above
with this :

Expand|Select|Wrap|Line Numbers
  1.     document.write("<div id=\"" + ParamID + "\">");
  2. }
  3. else
  4. {
  5.     document.write("<div id=\"" + ParamID + "\" class=\"print_only\">");
  6.  

and in you CSS file :

Expand|Select|Wrap|Line Numbers
  1. @media screen {
  2. .print_only {
  3.     display: none;
  4. }}
  5. @media print {
  6.     .print_only {
  7.         display: block;
  8. }}
  9.  

I placed both definitions in a @media rule for accessibility's sake.
Browsers that don't understand @media rules will ignore both, so they
will display the text on screen but at least they will also print it.
Of course you can extend the list of media that should or should not
display the text.

If you ever want to disable text hiding, just load a CSS file without
.print_only declarations, or remove these declarations dynamically.


Thanks, David. That seems to have done the trick.

RIck

Sep 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: David | last post by:
It's sad to say, but when using the AOL web site, like to send an email, they have a nifty capability such that when a window is resized, the textarea where the message is input expands not only...
2
by: Haines Brown | last post by:
This may seem a pointless question, but I'm trying work around an inconsistency between browsers. I have a template that contains a division that holds a text that sometimes exists and sometimes...
4
by: erikd | last post by:
I'm using an expanding tree menu based on the design from Dieter Bungers GMD (www.gmd.de) and infovation (www.infovation.de) named displayToc.js. The problem is that the script isn't working...
0
by: Hal | last post by:
How do you change the Background Color for a (collapsed) Date Time Picker control from the default white? (I can change every other color setting on this control like its background color when...
2
by: kevin | last post by:
I would like to remember the state of the nodes after the treeview gets disposed, but not necessarily after the app terminates so I don't need a disk file. I was thinking about using the tag...
11
by: Schraalhans Keukenmeester | last post by:
I have tried to collapse a long part of a text on my weblog using the following construct: <style> div.expand { display : none; } div.expand:hover (display : inline; } div.expand em {display :...
5
by: Milan Krejci | last post by:
the thing is that descentant branches i dont want to expand do expand. $id variable contains an array of branches i want the program to go through (alcohol's id -beer id etc) function...
0
by: Smokey Grindle | last post by:
I have a VB.NET application with the Report server 2005 .NET control on a form... when I run a report that has a document map with grouped items the map shows as a single collapsed node then I can...
2
by: deepakfordotnet | last post by:
Hi, First of all let me confess that I could not get the solution to the same problem from an earlier post Printing :by Mr.Richard MSL (dated September 24th 2006) working. (Replied by Mr.Walter...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.