How to run script automatically when topic is displayed?

This forum is for all Flare issues related to the Microsoft HTML Help target.
This target produces "CHM" files in the output.
Post Reply
GregHat
Jr. Propeller Head
Posts: 7
Joined: Wed Feb 11, 2009 5:21 pm

How to run script automatically when topic is displayed?

Post by GregHat »

I am new to both HTML help and scripting. I am using javascript to create a link that launches a pdf file when users click the link. How can I make the pdf file launch automatically when a topic is displayed?
i-tietz
Propellus Maximus
Posts: 1219
Joined: Wed Oct 24, 2007 4:13 am
Location: Fürth, Germany

Re: How to run script automatically when topic is displayed?

Post by i-tietz »

Care to post the js code and where and how you inserted it in the topic - i. e.: the code of the relevant parts of the topic?
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: How to run script automatically when topic is displayed?

Post by doc_guy »

Hi Greg,

Welcome to the MadCap forums.

I've never done any scripting in my Flare projects, so I'm not sure where you would need to put the script so that it wouldn't get pulled out during the build process. Maybe somebody else can point you in the right direction, or maybe you could contact MadCap Support (assuming you have a maintenance agreement) to get their input.
Paul Pehrson
My Blog

Image
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: How to run script automatically when topic is displayed?

Post by LTinker68 »

I'd recommend putting the Javascript code in a separate .js file, unless it's really small and you're only using it in one topic. If it's a lot of code or you're using it in multiple files, then you'll have to add a call to the JS file from every topic that'll use it -- or you add the call to a masterpage so that the JS is available in every topic. In either case, you'll have to open the topic(s) or masterpage in the Internal Text Editor and add the script tag to call the JS file, then add the onLoad string to the body tag, assuming you want the JS to run when the page loads.

Just make sure you properly structure the JS file, the script tag, and the onLoad string.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
GregHat
Jr. Propeller Head
Posts: 7
Joined: Wed Feb 11, 2009 5:21 pm

Re: How to run script automatically when topic is displayed?

Post by GregHat »

Thanks for everyones help.

The answer is to put onload="IDname.Click()" after the body tag, where IDname is the reference to the javascript link that users can click.

<body onload="IDname.Click()">

Now the pdf file launches as soon as the topic is loaded.
Post Reply