IWebViewCreateGlobalJavascriptObject Method Awesomium.NET 1.7.6Awesomium.NET
Create a global JavaScript object that will persist between all loaded pages, for the lifetime of this IWebView instance.

Namespace: Awesomium.Core
Assembly: Awesomium.Core (in Awesomium.Core.dll) Version:

JSValue CreateGlobalJavascriptObject(
	string name


Type: SystemString
The name of the object as it will appear in JavaScript.

Return Value

Type: JSValue
If this call succeeds, the returned JSValue will be of type 'Object' (see IsObject). You can check the reason why the call failed by calling GetLastError after this method.

InvalidOperationException The member is called on an invalid view. (See: IsLive)
NotSupportedException The operation is not supported on a Developer Tools Inspector view (see: IsJavascriptEnabled).
NotSupportedException Javascript calls are not supported when Javascript is disabled (see: IsJavascriptEnabled).
InvalidOperationException The member is called from inside a synchronous Javascript Execution Context.
ArgumentException The specified name is reserved. It either represents an HTML DOM object, or an object variable already available in the page. Use ExecuteJavascriptWithResult(String) after DocumentReady, to obtain this object.

Note Note
Starting with v1.7.5, the predefined OSMJIF JavaScript global object of our Javascript Interoperation Framework (JIF) available in all pages loaded in an Awesomium.NET view, allows you to communicate with the hosting view through the sendMessage(String, Any) and sendMessageAsync(String, Function, Any) JavaScript methods and the respective JavascriptMessage event; therefore, you no longer need to create your own global objects.
Global Objects can only contain the following JavaScript types as properties:
  • Number
  • String
  • Array
  • Null
  • Other Global Objects
  • Undefined

Global Objects will retain any custom methods that are registered (see Bind Overload).

Note Note
To create a child global-object, you should specify the full name with dot-notation for example: parentObject.childObject.

The parent object should exist before attempting to make any children.

Note Note
You can create global Javascript objects on a view, as soon as it goes live. (IsLive is true). On technology specific WebControls, you should wait for the NativeViewInitialized event. WebView components go live immediately after creation.
See Also