How to run script automatically when topic is displayed?
How to run script automatically when topic is displayed?
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?
Re: How to run script automatically when topic is displayed?
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?
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.
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.
Re: How to run script automatically when topic is displayed?
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.
Just make sure you properly structure the JS file, the script tag, and the onLoad string.
Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Re: How to run script automatically when topic is displayed?
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.
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.
