In the sample zip file you will find a ToolBook file and a .js file containing one Javascript, the js file is linked into the toolBook file. For more information on linking external JaveScript files into ToolBook see this excellent article written by Denny Dedmore of Sumtotal.
Lets look at the .js file first:
The .js file contains one function which does all the heavy lifting in the sample, so lets take a look at it.
function tbfunction_SetObjectHTMLText(obrefName,htmtxt) {
var objRef = TBK.Persistence.dereference(obrefName);
objRef.setProperty("htmlText",htmtxt);
}
The function takes two parameters obrefName and htmtxt.
obrefName must be an ToolBook HTML object reference, the format looks like this p0.o0 (which translates to: the object with idnumber 0 on the page with Idnumber 0). So p2.o4 is the object with idnumber 4 on the page with Idnumber 2
htmtxt is the HTML we want to inject. This could be something like: <a href="www.toolbookconsulting.com">My website</a>
The next line
var objRef = TBK.Persistence.dereference(obrefName);
resolves the obrefName parameter as an object reference
the last line sets the htmlText of the object to the value of the htmtxt parameter.
objRef.setProperty("htmlText",htmtxt);
Now lets look at out ToolBook sample file:
Besides labels and headers the file contains 4 important objects:
- field “html” – this is where you enter the HTML
- field “HTMLOutPut” – this is where the HTML you enter above is rendered, note the field has no without border so you cannot see it until HTML is injected into it
- field “obRef” – a hidden field whichh contains the ToolBook HTML object reference to field “HTMLOutPut” – check out the SharedScript of the field for an example on why Openscript is still usesfull even if you are developing for HTML (beyond the scope of this article but I’ll cover that in a later post)
- button “inject HTML” – this button have action editor code to call the JavaScript function in the JS file when its clicked. See the screen shots below for more details.
Use the execute Script feature to call the external JavaScript Post

Edit the properties of the the execute Script Feature to specify the parameters required by the function.
I hope you have enjoyed this article, drop me a comment if you have any comments or questions
Cheers
Tomas
IMPORTANT: This example require obfuscation to be turned off during HTML export in ToolBook.
If you don’t know what Obfuscation is the one minute explanation of what Obfuscation is comes here:
Generally when code is obfuscated, human legible code is replaced with human illegible code, so a function called MySecretFunctionWithaLongName() might be reduced to _aF() when obfuscated.
This has two purposes, the code is more difficult to hack figure out hence more secure, and the filesize of scripts is reduced improving performance of the code.
Note while It is possible to achieve the same with obfuscation turned on but as the code is illegible for humans it proves very bad as a sample.