Multiple methods of using SilverLight to call javascrip

Source: Internet
Author: User

Although silverlight is sufficient for developing various page types, we consider the following scenario: What should we do if we want to obtain the browser width? In silverlight, this method is not available for direct use, but we know how to use webpage special effects to get the browser width. I will introduce two methods to call javascript.

1. execute javascript in silverlight

First, add the namespace: system. windows. browser;

Htmlpage. window. eval ("alert ('javascript executed ')");


 

2. Call the javascript function on the host page:

For example, we have the following javascript Functions on the host page:

 

Function prompt (){
Alert ("executed host js ");
}
 

 

Add the following code to silverlight:

 

Scriptobject urivirtual = htmlpage. window. getproperty ("prompt") as scriptobject;
Urivirtual. invokeself ();


 

In this way, the prompt function on the host page is called.

About silverlight

Microsoft silverlight is a web front-end application development solution developed by microsoft. It is one of the main application development platforms for microsoft's rich internet application policies, provides Solutions for multimedia (including audio and video streams and sound streams) and highly interactive front-end applications in web applications using browser plug-ins. It is also a Microsoft ux (user experience) one part of the Strategy is Microsoft's attempt to clearly split and collaborate with art design and program developers to develop applications.

Related Article

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: info-contact@alibabacloud.com 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.