Using Silverlight to invoke Javascrip multiple methods

Source: Internet
Author: User
Tags silverlight

Although Silverlight is enough to meet our needs for developing various types of pages, we consider the following scenario: What do we want to do with the width of the browser, there is no way to use it directly in Silverlight, but we know how to use the web effects to get the width of the browser, I'll introduce two ways to invoke JavaScript.

1. Execute JavaScript inside Silverlight

First add namespaces to the page:;

htmlpage.window.eval ("alert (' Execute JavaScript ')");

2. Invoke the Host page JavaScript function:

For example, we have the following JavaScript functions on the host page:

function prompt () {
Alert ("Execute the host's JS");

We add the following code to Silverlight:

ScriptObject urivirtual = Htmlpage.window.getproperty ("prompt") as ScriptObject;
Urivirtual.invokeself ();

So we call the prompt function on the host page.

Introduction to Silverlight

Microsoft Silverlight, a Web front-end application development solution developed by Microsoft, is one of the major application development platforms for Microsoft's Rich Internet Application (application) strategy, in the form of browser Plug-ins, Provides a solution for multimedia (including audio and video streaming) and highly interactive front-end applications in Web applications, as well as a part of Microsoft's UX strategy and one of the attempts by Microsoft to identify and collaborate on the work of art design and program developers to develop applications

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.