js script error 'getElementsByTagName'

This forum is for all Flare issues related to the Microsoft HTML Help target.
This target produces "CHM" files in the output.
Post Reply
RobinS
Propeller Head
Posts: 33
Joined: Mon Oct 22, 2012 6:27 am
Location: Scotland, UK

js script error 'getElementsByTagName'

Post by RobinS »

A customer is reporting that they get the following message when opening the .CHM file (which then proceeds to work fine...):
"Unable to get value of the property 'getElementsByTagName': object is null or undefined."

URL points to .../SkinSupport/MadCapToolbar.js
The offending code is:
FMCGetSkin(function (xmlDoc) {
var buttons = null;
var nodeName = gIsTopicToolbar ? "TopicToolbar" : "Toolbar";
var toolbarNode = xmlDoc.getElementsByTagName(nodeName)[0];

I can see similar issues with js on this forum, but they all seem to be webhelp/browser issues.

Any tips?
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: js script error 'getElementsByTagName'

Post by NorthEast »

I had a similar error, which was related to making CSH calls with a null value to a CHM file which has a topic toolbar.

The workaround suggested by MadCap support that fixed the problem was to select a Startup Topic in the target (General tab), rather than leave it set as (default).
MadCap support wrote:We were able to replicate the bug with a sample project and test application.

As a workaround, please try selecting a startup topic and let me know if the JS error still appears. If the application calls a topic, it should work fine. Calls to the base index or TOC cause the script errors.

The bug is exactly what you previously described where a null value is being used in the CSH call.
RobinS
Propeller Head
Posts: 33
Joined: Mon Oct 22, 2012 6:27 am
Location: Scotland, UK

Re: js script error 'getElementsByTagName'

Post by RobinS »

Many thanks for that Dave - I did have a 'default' startup topic, so have done what you suggest and will get customer to test - can't replicate here. If problem persists will raise with MC support.
Post Reply