Skip to main content
Known Participant
March 13, 2008
Question

Inserting Javascript

  • March 13, 2008
  • 5 replies
  • 1647 views
Hi,
I'm trying to insert some javascript code into a RoboHelp page - just some javascript to make a link save as a favourite. Is there any trick or method in putting javascript into RoboHelp? Every time I try, I get script errors that I do not get when using with a different html editor.

I've made a menu button that when clicked will add the current page to the users favorites, but can't seem to get any javascript to work within the html editor and sometimes Robo will mess with the code inserting its own characters.

Thanks.
This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

Inspiring
March 13, 2008
Hi hughbetcha,

I haven't seen RoboHelp alter code within a <SCRIPT> tag, but the WYSIWYG editor is notorious for messing with your HTML. One of the conflicts that can occur with scripts is that RoboHelp adds its own script file to every topic in order to support DHTML. It is possible, but unlikely, that you might define a constant or name a function that is already in use.

I'm confused by your statement "can't seem to get any javascript to work within the html editor," as the script won't work from the editor. You will need to compile before you test it. But I suspect you are doing that correctly.

What error messages do you get? If you compare the script that worked from one editor, to that which didn't from RH, what are the differences?

Try removing the <SCRIPT LANGUAGE="JavaScript" TITLE="BSSC Special Effects" SRC="BSSCDHTM.js"> </SCRIPT> line and also delete all the ONLOAD, etc. satements in your BODY tag in a topic (from your True Code editor - don't return to your WYSIWYG editor before compiling) and see if your custom script works in that topic. That will let you know if there is a conflict with RoboHelp's code.

John
MergeThis
Inspiring
March 13, 2008
Three things:

1. When entering JavaScript into TrueCode, Save All before switching to WYSIWYG mode.

2. Be very careful not to introduce line breaks within sections of the script. Usually, I filter any code I've downloaded from sites that offer them through Notepad, by pasting the code and turning off Word Wrap. That tells me exactly where the only allowable line breaks should appear, so that I can verify the format after pasting it into RH.

3. Pay special attention to where in the topic you should place the <SCRIPT call (sometimes in the <HEAD> section, sometimes after the <BODY> tag, sometimes before the </BODY> tag, etc.).


Good luck,
Leon
Known Participant
March 14, 2008
Thanks for the advice. I copied the code into WordPad first and then brought into Robo. This seemed to fix the problem previously where Robo was changing the code slightly. I should mention I'm using RoboHelp 7 HTML and publishing to RoboHelp 7 Server.

Again, this javascript is supposed to make an image I created a link that will open up the Favorites window promting the user to save it to their Favorites. When I preview the page, my image does not appear, but the "X" empty image when clicked does open up Favorites, so the javascript seems to work. With the image being referenced within the Javascript, in the Design view the image does not display (just get that red box indicating there is a script there).

I published the project to the server to see how it would appear, but I don't even get the empty image there so there's nothing to click on to execute the javascript. Also, when publishing was completed I noticed the image did not get published to the server, so I assume I cannot include the image within the javascript....in order for an image to be published to the server it needs to be viewable in Design view??? I can try the script without using an image as a link, but am wondering if I just need to get the image published to the server for it to work?

I've attached the javascript code I used. Thanks!