4.8 RES-Reach and Javascript

    Javascript can be defined and used in a RES-Reach template file. More importantly, RES-Reach tags and replacement variables can be used to dynamically create Javascript code before sending it to the Browser.

    The example below shows how Javascript code should be written in a RES-Reach template file. Note that Javascript curly braces must be escaped so that they are not interpreted as RES-Reach replacement variables.

    If your Javascript code does not need variable replacement, then place it in a distinct file and include it using the "@@" file variable syntax (which does not do variable replacement). In this case, the curly braces need not be escaped.

    Warnings!

    Example:

    The "flash" function defined below also demonstrates how recursive variable replacement can be useful. This function is defined within a single file which is included in a set of template files. As the "NBT" variable contains the name of the current template file being processed, the effect of this function is to display status line text specific to the template being processed.

    <SCRIPT>
    <!--
    //
    function flash(txt) \{
    window.status = txt;
    setTimeout("window.status='{@{NBT}.ENG}';",3000);
    return true;
    \}

    function selectItem() \{
    top.MainMenu.document.itemForm.submit();
    return true;
    \}

    // -->

    </SCRIPT>