It is possible to run JavaScript code in the context of an element or in global context.
Element Context
If you need access to a specific property of an element and it is not available via HTMLObject API follow this pattern:
var propertyValue = Navigator.ExecJS('return el.<property_name>;', <html_object>);
var formAction = Navigator.ExecJS('return el.formAction;', SeS("Username_"));
var formAction = Navigator.ExecJS("return el.formAction;", Navigator.Find("//input[@id='MainContent_LoginUser_UserName']"));
To make it compatible with Selenium WebDriver use arguments[0] instead of el.
var formAction = Navigator.ExecJS('return arguments[0].formAction;', SeS("Username_"));
Global Context
To access parent document or window of a specific element use
var result = Navigator.ExecJS("<your_code>", <html_object>);
var url = Navigator.ExecJS("return document.location.href;", SeS("Username_")));
var url = Navigator.ExecJS("return document.location.href;", Navigator.Find("//input[@id='MainContent_LoginUser_UserName']"));
If you need to execute a code not related to a specific element (e.g. for the topmost document or window) do not pass second parameter to Navigator.ExecJS and assign the result of your code to execResult variable.
var url = Navigator.ExecJS("execResult = document.location.href;");