Copy link to clipboard
Copied
Hi
(using RH 8.0.2, building chm/webhelp, displaying webhelp in FF 3.6+)
I've got a clickable text ("Click here to print the topic") in my topic footers which displays dropdowns and expanding texts and opens the print dialog. Works well in IE, but in Firefox nothing happens. Using a Web developer tool to find the error, I get the error message "arrayofDivs is undefined" for the highlighted line in the script below.
I have borrowed the script from the Robohelp experts in this forum, and have no javascript skills, so I'm looking for any clue on how to fix this script for Firefox. Any help is greatly appreciated!
The script:
<script type="text/javascript" language="JavaScript1.2">//<![CDATA[
<!--
var arrayofDivs = document.all.tags("DIV");
function showEm() { for (x=0;x<arrayofDivs.length;x++) { arrayofDivs
}
function hideEm() { for (x=0;x<arrayofDivs.length;x++) { arrayofDivs
}
function printEm() { ;showEm();setTimeout('window.print()',50)}
//-->
//]]></script>
The link:
<p align="center"><a href="chap01\#" onclick="JavaScript:printEm()">Click here to print the topic</a></p>
Best regards,
Torgeir
Hi,
Replace document.all.tags("DIV") by document.getElementsByTagName('div')
I think that you better show the dropdowns using css. Easier and less code. Amend your link like this:
<p align="center"><a href="javascrip:void(0);” onclick="window.print()">Click here to print the topic</a></p>
In your style sheet, add the following (using an external editor):
@media print{
div.droptext { display: block !important; }
}
When someone prints, all dropdowns are shown. This doesn’t make any cha
...Copy link to clipboard
Copied
Hi,
Replace document.all.tags("DIV") by document.getElementsByTagName('div')
I think that you better show the dropdowns using css. Easier and less code. Amend your link like this:
<p align="center"><a href="javascrip:void(0);” onclick="window.print()">Click here to print the topic</a></p>
In your style sheet, add the following (using an external editor):
@media print{
div.droptext { display: block !important; }
}
When someone prints, all dropdowns are shown. This doesn’t make any changes to the page, so if the user has dropdowns shown, they won’t be closed.
Greet,
Willam
Message was edited by: W. van Weelden - Email didn't come trough correct.
Copy link to clipboard
Copied
Your suggested fix works fine in both FF and IE. And in the chm 🙂
Thanks, Willam! You made my Friday
Best regards,
Torgeir
[EDIT: Willam! sry! :-)]
Copy link to clipboard
Copied
Hi, I want to have a link in my webhelp to print the topics including dropdown text. After googling, I found this thread, and did the following to my template:
<script type="text/javascript" language="JavaScript1.2">//<![CDATA[
<!--
var arrayofDivs = document.getElementsByTagName('div');
function showEm() { for (x=0;x<arrayofDivs.length;x++) { arrayofDivs
}
function hideEm() { for (x=0;x<arrayofDivs.length;x++) { arrayofDivs
}
function printEm() { ;showEm();setTimeout('window.print()',50)}
//-->
//]]></script>
@media print{
div.droptext { display: block !important; }
}
After I regenerate and open the output in IE8, I click the link and the print dialog appears. It prints as expected/desired, but then the browser shows The webpage cannot be displayed. The address bar shows "javascrip:void(0);" and I have to click Go back to previous page to return to my help.
If I open in Firefox, after printing I get the message "Firefox doesn't know how to open this address, because the protocol (javascrip) isn't associated with any program. [OK]".
Obviously there's an issue with the a href="javascrip:void(0);" section above, but that's what Willam suggested and it apparently worked for Torgeir.
What have I done wrong?
Copy link to clipboard
Copied
Grr, why won't my script show up? Anyway, it's the script Torgeir initially provided above with the change suggested by Willam.
Copy link to clipboard
Copied
Hi,
I don't know about the script. I thought it was me.
This method is quite old. Try http://www.wvanweelden.eu/robohelp/scripts/toolbarscripts for a script that works. (It adds buttons in the toolbar.) If you like, I can also create a version you can use in the topics themselves.
Greet,
Willam
Copy link to clipboard
Copied
Hi Willam, thanks for the reply. I did come across that procedure from Peter Grainge's site, but I don't use twisties so thought I couldn't use it.
Copy link to clipboard
Copied
I had an error when I tried to update my posting - Firefox seemed to print ok, but didn't include the dropdown content.
In any case, Willam has indicated that that method is outdated.
I wanted to add that I don't care if it's a toolbar button or a link in the topic footer, as long as the user can print with dropdowns.
Copy link to clipboard
Copied
The wording on my site is
Toolbar Show / Hide / Print including dropdowns / Print as displayed Buttons - Willam van Weelden's new toolbarscripts01.js scripts allow you to add buttons for any or all of the options shown.
See www.grainge.org for RoboHelp and Authoring tips
Copy link to clipboard
Copied
Yeah, that'll teach me not to skim so fast!
Thanks Willam, everything works perfectly now.
Copy link to clipboard
Copied
Great. I'm glad it works for you.
Greet,
Willam
Copy link to clipboard
Copied
Hi,
No problem there. As long as you don't use twisties or use the default RoboHelp twisties, the script will work. When you use a custom twisty method, the script probably works, but will not update your twisties.
Greet,
Willam