Accessing JavaScript from Silverlight
It is now time to perform the reverse process. We will access the functions defined in JavaScript from our Silverlight application. In this sense, the working is a little bit simpler, since we do not have to do anything special to define functions in JavaScript. They only have to be accessible for the page in general.
HtmlPage object
Before continuing, let's look in detail at the HtmlPage object. This class offers functionality to access and handle the DOM of the page. Through the HtmlPage object, it is possible to:
Access/Invoke JavaScript functions
Register a Silverlight object in the HTML page, making it accessible from JavaScript
Obtain an HtmlDocument object to manipulate the page DOM
From the HtmlPage object, an object of the type HtmlWindow is obtained via the Window property on which JavaScript functions will be invoked.