Related sites:
More related sites:

Naurtech Support Wiki

Navigation: Print | Search | Wiki Home | Back to www.naurtech.com

Support Topics

  • Home
  • Usage Videos
  • Scripting
  • Web Browser
  • Download & Setup
  • License Registration
  • Cold Boot Persistence
  • Barcode Scanner
  • Remapping keys
  • Sounds & Tones
  • Lockdown & Fullscreen
  • Misc. & Usage Tips
  • Tools & Utilities

Wiki Actions

  • View
  • Edit
  • Print
Naurtech Corporation Copyright. All rights reserved.

Set focus to Web page input on session switch

When you switch from a terminal emulation session to a web browser session, the cursor focus does not end up at the input field on the web session form. This sample script demonstrates how to force this input focus.

This script is specific to SAP WebConsole. It is fired automatically when the session is switched. It looks at the web page to decide where to place the focus. It looks through the document object for the HTML page to find input / edit elements. If found, it gives that element keyboard input focus.

To download the script, right mouse click and "Save Target As..." SessionSwitchInputFocus.js

// OnSessionSwitch
// 
// SAP - set to last focus location on session switch
//
function OnSessionSwitch( session, previousSession )
{
    var document = CETerm.Session( session ).Browser.Document;

    if (document != null &&
        document.form1 != null &&
        document.form1.FOCUS != null)
    {
        function setFocus( index )
        {
            // Look for valid edit element
            var element = "document.form1.edit_" + index;

            if (eval( element ) != null)
            {
                // Set focus to element
                eval( element + ".focus();" );
                return 1;
            }

            // Look for valid pswrd element
            element = "document.form1.pswrd_" + index;

            if (eval( element ) != null)
            {
                // Set focus to element
                eval( element + ".focus();" );
                return 1;
            }

            return 0;
        }

        // Look for valid field index
        var index = document.form1.FOCUS.value;
        if (index > 0)
        {
            // Have valid index
            setFocus( index );
        }
        else
        {
            // Set to first valid field
            var i = 1;
            while (setFocus(i) == 0 && i < 9)
            {
                i++;
            }
        }
    }
}

The article is provided as a service to current and perspective Naurtech customers. Trademark references made to various companies and their products belong to the respective companies. All information is provided as is. For questions, please contact us at  support@naurtech.com.