Table of Contents
JSInitCode Property

Gets or sets the JavaScript code to be run immediately after the window has been created.

Syntax
 public String JSInitCode { get; set; }
Remarks

This property can be used to initialize some global variables in the browser window, or can even be used to rewrite some default JavaScript function. For example, if you wish to disable the built-in JavaScript print function, you can set this property to "window.print=function(){};". The following code demonstrates how to run additional JavaScript code after the page has been loaded:

webView.JSInitCode = @"
    window.addEventListener('load', function() 
    {{
        alert('Page loaded! Now do something!');
    });";

JSInitCode is only run once per JavaScript context. So while you can set this property multiple times to different values, only the value when the JavaScript context is created is used.

See Also