Html,javascript calling the Winfrom method

Source: Internet
Author: User

---restore content starts---

Objective:
Add a click event above the animation and call the Winfrom method via JavaScript

1. Create a page

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Security.Permissions;usingSystem.Runtime.InteropServices;namespacedemo{
Sets the range that can be called [PermissionSet (SecurityAction.Demand, Name="FullTrust")] [ComVisible (true)] Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } Private voidWebbrowser1_documentcompleted (Objectsender, WebBrowserDocumentCompletedEventArgs e) { } Public voidShowMsg (stringmsg) {MessageBox.Show (msg); } Private voidButton1_Click (Objectsender, EventArgs e) {WebBrowser2.Document.InvokeScript ("Run",New Object[] {"csharefunction" }); } Private voidWebbrowser2_documentcompleted (Objectsender, WebBrowserDocumentCompletedEventArgs e) { } Private voidForm1_Load (Objectsender, EventArgs e) { stringFlashuri ="d:/text.html"; This. Webbrowser2.url =NewUri (Flashuri); Webbrowser2.objectforscripting= This;//specifically exposed objects, where custom objects can be exposed } }}

2. HTML page

<HTML> <Head>   <MetaCharSet= "Utf-8" />  </Head>  <Body>   <imgsrc= "Bankpay.gif"style= "position:absolute; width:100%; top:0px; left:0px; right:0px ; bottom:0px; height:100%; z-index:100;"  />   <Divstyle= "position:absolute; width:100%; top:0px; left:0px; right:0px ; bottom:0px; height:100%; z-index:101;"onclick= "Run (' browser open ')">11111</Div>    <Scripttype= "Text/javascript"CharSet= "Utf-8">    functionRun (str) {WINDOW.EXTERNAL.SHOWMSG (str); }   </Script>  </Body></HTML>

3, Note: If the use of flash, the page is not able to get to the Click event

4, Flash solution, by converting to GIF animation pictures to solve

---restore content ends---

Html,javascript calling the Winfrom method

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.