I've written a JavaScript function that reformats the main toolbar when the help file is loaded. I first incorporated this function into HTML5 Help (successfully) and am now trying to get it to work in WebHelp. But I have come up against an apparent discrepancy in the way window.onload works in the two formats.
As you may know, in JavaScript, the value assigned to window.onload must be a function name, not a function call. So you refer to the function without the parentheses. (Including the parentheses would execute a call to the function during assignment, and expect a function as a return value. This is valid but not normally what you want to do.)
So, this works in HTML5 Flare output:
Code: Select all
function talkToMe() {
alert("Hi.");
}
window.onload = talkToMe;However, when I include the exact same code in WebHelp output, the JavaScript is not executed. To get it executed, I have to add parentheses:
Code: Select all
function talkToMe() {
alert("Hi.");
}
window.onload = talkToMe();I tried inserting the code in the both the WebHelp Toolbar and the Topic Toolbar JavaScript boxes in Flare.
All I want to know is: why does the correct syntax of window.onload execute for HTML5 Help output, but not for WebHelp output? Has anyone else had this problem?
Thanks.