JavaScript extensions: window.external

Applies to IE Browser publications only

HTML Executable features its own script language HEScript which allows you to control your publications. Since you can also use JavaScript in your HTML pages, the Dynamic HTML Object Model was extended so you can also control your publication through JavaScript: some JavaScript "external" commands (a.k.a. methods) are accessible from the window.external object.

List of available window.external methods

Method namePrototypeDescription, comments
CloseCurrentWindowprocedure window.external.CloseCurrentWindowCloses the current window (it can prompt end users).
GetGlobalVariablefunction window.external.GetGlobalVariable(Name, DefValue)Returns the value of the global variable whose name is Name. If the global variable does not exist, the DefValue is returned.
Similar to GetGlobalVar HEScript function.
SetGlobalVariableprocedure SetGlobalVariable(Name, Value;  IsStored: WordBool)Sets the Value of a global variable whose name is Name. If IsStored is true, the global variable is persistent: its value will be stored and restored the next time the publication is run.
Similar to SetGlobalVar HEScript function.
RunHEScriptComprocedure RunHEScriptCom(ComLine)
 
This function is the most used: it lets you execute a HEScript function. It is similar to the hescript:// protocol, except that you specify the command line via ComLine.

Syntax for ComLine:

[HEScript script name].[procedure/function name]|Param1|Param2|....|ParamN.

Please see the How to call a script help topic.

GoToPageprocedure GoToPage(URL, Window)This function causes the publication to navigate to the URL specified by URL and in the window named by Window. Window should be left to blank.
HEPrepareFilefunction HEPrepareFile(Path; Operation: Integer)This function is used internally by HTML Executable; do not use it yet.
GetStringfunction GetString(ID)Returns the resource string whose name is given by ID.
ShowPopupprocedure ShowPopup(Name, URL, Width, Height, Top, Left, Param)Opens a new popup window. More information about this function.
ClosePopupprocedure ClosePopup(name)Closes the popup window whose name is given by "name". More information about this function.
SetUIPropprocedure SetUIProp(ID, PropName, PropVal)Sets the value of the specified property of a control whose name is given by ID.

Similar to SetUIProp HEScript function.

Examples

1. To call a HEScript function, you can also use this JavaScript function:

function executecom(sname)
{
window.external.runHEScriptCom(sname);
return 0;
}

For instance, if you want to call the HEScript procedure "UserMain.Procedure1", use: javascript:executecom("UserMain.Procedure1") or javascript:window.external.RunHEScriptCom("UserMain.Procedure1").

2. To display a resource string in your HTML pages, use this code:

<script language="JavaScript">
document.write(window.external.GetString("[Name]"));
</script>

where you replace [Name] by the name of the resource string you want to display.

Live example: we used this script to display the title of this publication:

<script language="JavaScript">
document.write(window.external.GetString("SPubTitle"));
</script>

See these topics also:

Introduction to scripting

How to call HEScript procedures/functions?