Skip to main content
December 13, 2006
Answered

Printing Button on WebHelp Skin

  • December 13, 2006
  • 13 replies
  • 3083 views
Hi,

I am generating webhelp.

I was able to follow the instructions and create a custom button on the WebHelp Skin and to print the topic which is open. When I try to print it prints a page with the Toolbar of the skin but no contents..

Code used

if (top.frames[1].frames[1].frames[1] != null)
{
top.frames[1].frames[1].frames[1].focus(); window.print();
}
else
{
top.frames[1].frames[1].focus(); window.print();
}

Please help
This topic has been closed for replies.
Correct answer Roger_N
kewel -

It seems that IE tabs don't affect the frame references.

The script you were using instructed the browser to, if the toolbar frame exists, print it; otherwise, print the contents frame. Well, you always have the toolbar frame if you see the print button, so it makes no sense.

All you really need is the second print statement in your Inline Javascript:

function PrintIt()
{
top.frames[1].frames[1].focus(); window.print();
}

...and be sure to add PrintIt() to your onclick event.

13 replies

January 17, 2007
Hi

emailed Roger

Thx
Kewal
January 4, 2007
Hi Roger ,

I have removed the script from the template, but am wondering if am suppose to use this script on my target page?do you mean all topics of the help?this would be lots of copy/pasting I dont mind but would be lot of work if any changes to the script is required at a later stage..may be in a later version of RH..or something like that..

hmm..testing the script in a demo project's topics..

thx
Inspiring
January 4, 2007
Kewel -

The script is just an investigative tool. Use it to determine exactly what your path is to that bsscright frame. Once you post it into a topic, you can read the name(s) of the frames in your project, and create the appropriate path for the print() command. You will want to remove the script entirely once you have figured out what the frame hierarch is. something like "frame[0].frame[0].bsscright.focus(); print(); or something like that....
Roger_NCorrect answer
Inspiring
January 11, 2007
kewel -

It seems that IE tabs don't affect the frame references.

The script you were using instructed the browser to, if the toolbar frame exists, print it; otherwise, print the contents frame. Well, you always have the toolbar frame if you see the print button, so it makes no sense.

All you really need is the second print statement in your Inline Javascript:

function PrintIt()
{
top.frames[1].frames[1].focus(); window.print();
}

...and be sure to add PrintIt() to your onclick event.
Inspiring
December 27, 2006
Kewel -

That script shouldn't really be in your template, as it doesn't help to print anything, it just reflects the hierarchy of frames in the current topic. You would use the information it provides to create your path in your print statement. Delete it from the page once you have figured it out.

I'll give it a look when I access a project later today.

December 26, 2006
Hi Roger,

Thx for the script, much appreciate.

I did the below:
1. I used the script in the template that my topics are using, so I pasted the script in my template. For the print button I used both scripts from Rick and the script I had - None of this worked, no print command would execute.

2. So I used your script in one topic only, what I noticed in my output for that topic it displayed the below, the print button on the screen worked but it prints only toolbar like before.
file:///C:/abcd%20and%20abcd/abcd/Desktop/Output/New%20Folder%20(2)/NewProject.htm
contains:
The frame named , frames[0] (Title: "WebHelp Navigation Toolbar", file:///C:/abcd%20and%20abcd/abcd/Desktop/Output/New%20 2)/whskin_tbars.htm)
The frame named , frames[1] (Title: "", file:///C:/abcd%20and%20abcd/abcd/Desktop/Output/New%20%20(2)/whskin_frmset01.htm), which contains
The frame named , frames[0] (Title: "", file:///C:/abcd%20and%20abcd/abcd/Desktop/Output/New%20%20(2)/whskin_frmset010.htm), which contains
The frame named , frames[0] (Title: "WebHelp Navigation Mini-bar", file:///C:/abcd%20and%20abcd/abcd/Desktop/Output/New%20%20(2)/whskin_mbars.htm)
The frame named , frames[1] (Title: "Navigation Pane", file:///C:/abcd%20and%20abcd/abcd/Desktop/Output/New%20%20(2)/whskin_pdhtml.htm), which contains
The frame named , frames[0] (Title: "Table of contents", file:///C:/abcd%20and%20abcd/abcd/Desktop/Output/New%20%20(2)/whtdhtml.htm)
The frame named bsscright, frames[1] (Title: "advance search", file:///C:/abcd%20and%20abcd/abcd/Desktop/Output/New%20%20(2)/advance_search.htm)

I guess am doing something wrong, not sure what. Doing some more thinking and troubleshooting lets see what happens.

Thx again
December 21, 2006
Hi Brj311,

Thx for the script, I agree it will work.
But this is not something that I can use in the webhelp skin custom button.

Not sure if javascript has got some tag known as "tab.print" as window.print in IE7 should not work due to the tab feature..

Not sure if am right or not..

Inspiring
December 26, 2006
Kewel -

Paste this script into your target page; it will outline what frames/tabs are involved. You can build your print() based on the structure it displays, but you will need to accomodate both versions of IE, so be sure to include a test in your print function to determine which frames exist (similar to your IF statement in your first post).
January 22, 2007
Hi All,

Thx for your help Roger, this is now working all fine.
The problem was with my IE not sure why or how!!
I tested it on developers computer IE and it worked just fine.

Guess I should have done this ages back, sorry my bad!

Thx heaps to Roger and others
December 14, 2006
hmm..still not able to figure this out..
any help?
December 20, 2006
here's the script i use. I just added it to the template used on each page (in the footer).

I can't remember where i found it (either Rick or Peter's site).




<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

var message = "Print This Page";

function printpage() {
window.print();
}

document.write("<form><input type=button "
+"value=\""+message+"\" onClick=\"printpage()\"></form>");

//-->
December 13, 2006
ahh..got it..the problem was with IE7 tab function..

using any of the below script would only print the frame..the script does not work for tabbed windows..

javascript:parent.frames[1].bsscright.focus();window.print();

OR

if (top.frames[1].frames[1].frames[1] != null)
{
top.frames[1].frames[1].frames[1].focus(); window.print();
}
else
{
top.frames[1].frames[1].focus(); window.print();
}

So yes Rick, the script needs some revision..

Any help on that?
December 13, 2006
hmmm...

well some more troubleshooting...

Using the code I was able to print the default page that opens up, i.e. Home page. But when I open any other page it will just print the toolbar..

December 13, 2006
Not yet will do it soon..

But even if it works in <IE7 is not good, as my help can be used by any version of IE's or other browsers.

Is there another way to slove this?
Captiv8r
Legend
December 13, 2006
Hi again

If my hunch is correct and it is an IE 7 specific issue, I'm guessing the scripts will need revising.

Cheers... Rick
December 13, 2006
And forgot..
using IE 7.0.5450.4
Captiv8r
Legend
December 13, 2006
Hmmm, could be that IE7 is the culprit here. Have you tried this using an earlier version of IE?