Skip to main content
Known Participant
November 10, 2009
Question

Print button from "Skinny on Skins" not working in Firefox

  • November 10, 2009
  • 2 replies
  • 1359 views

I've added the Print button to the webhelp skin and this works great in IE, but not in Firefox. I click the print button in Firefox and nothing happens. The javascript I added is as follows:

javascript:parent.frames[1].bsscright.focus();var arrayofDivs = parent.frames[1].bsscright.document.all.tags('DIV');for (x=0;x<arrayofDivs.length;x++) { arrayofDivs.style.display = 'block'; };setTimeout('window.print()',50);

Any ideas would be much appreciated.

Robohelp version: 7

Tested in Firefox 3.0.10

And I just want to say that the Skinny on Skins help file is fantastic and I refer to it often.

This topic has been closed for replies.

2 replies

Inspiring
December 9, 2009

This is a fantastic piece of code, thank you VERY much for posting it here.

I'm running into 1 specific problem with it however,

I'm displaying PDFs in my topic pane sometimes, and this breaks the script in IE.

I wouldnt expect it to work, and of course there is the alternative Print button that the PDF has itself, however with it being there I'm sure users will attempt to use it, and it causes a rather nasty error.

In firefox, and chrome the button works, but IE8 sends this back instead. (haven't tested on previous versions of IE)

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Wed, 9 Dec 2009 16:01:36 UTC


Message: Access is denied.

Line: 26
Char: 1
Code: 0
URI: file://file01/path/path/path/path/Release_Notes/whskin_tbars.htm

~That line of code it refers to in tbars.htm is the "var arrayofDivs = parent.frames[1].bsscright.document.getElementsByTagName('div');" from the script.

Any one have any ideas on why this is failing?

Thanks. If I can get a solution from one of our Dev's ill post it up.

Inspiring
December 9, 2009

Well I had no luck, after much reading it seemsits an IE security thing.

It 'should' work if the file is from the same domain as the site, which mine is, but apparently it will fail if its being looked at locally.

See these site for info.

http://codingforums.com/showthread.php?t=8473

http://www.webdeveloper.com/forum/archive/index.php/t-54903.html

In the mean time I added a piece to the code to catch the error and display a message to the user.

Because there is the 2nd print button on the PDF toolbar, users are instructed to use that instead. Better than the horrible error that IE throws.

changed code

var printAction = function()
{
var topicPane = top.frames[1].frames[1];
topicPane.focus();
try {
var arrayofDivs = parent.frames[1].bsscright.document.getElementsByTagName('div');
for (x=0;x<arrayofDivs.length;x++)
{ arrayofDivs.style.display = 'block'; };

topicPane.print();

}

catch(err)
       {
txt="Sorry, but you must use the Print button in the PDF toolbar.\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
       }

}

ChrodgersAuthor
Known Participant
December 9, 2009

Thanks for this info! I wasn't aware of this issue, or of a solution.

Peter Grainge
Community Expert
Community Expert
November 10, 2009

There's a similar script on my site in Snippets. See if that deals with this problem.


See www.grainge.org for RoboHelp and Authoring tips

Follow me @petergrainge

Use the menu (bottom right) to mark the Best Answer or Highlight particularly useful replies. Found the answer elsewhere? Share it here.
ChrodgersAuthor
Known Participant
November 10, 2009

Thanks Peter! I've referred to your site many times over the years.

I found two snippets related to adding a Print button on your site.

Snippet 24 worked great in Firefox and IE, but didn't print all the expanding and drop-down text. Could this script be modified to do this? If so, does anyone know how?

Snippet 5 is related to adding a print icon to a topic, correct? I'd like to add the Print button to the toolbar and print all expanding/drop-down text. The script I mentioned in my intial post did this, it just didn't work in Firefox.

Thanks!

Peter Grainge
Community Expert
Community Expert
November 10, 2009

Sorry but you are going to need someone who can write a script that brings these things together.


See www.grainge.org for RoboHelp and Authoring tips

Follow me @petergrainge

Use the menu (bottom right) to mark the Best Answer or Highlight particularly useful replies. Found the answer elsewhere? Share it here.