Interaction between ActiveX controls and Javascript in Web pages. js calls ActiveX functions.

Source: Internet
Author: User
Javascript calls functions in ActiveX Controls
The key to this interaction is to add external methods to the interface class. The procedure is as follows:
1. Create an MFC ActiveX project in. net
2. in the class view, you can see a "project name + lib" item at the bottom. The icon is different from the class icon above. expand it and you can see three items, the following is how to add an external function under the second item ("_ d + project name ").
3. Expand the second item and you can see that there is an aboutbox (void) function below, which means some ActiveX controls already have an interface for external interaction. Right-click the interface (named "_ d + project name") and choose "Add-> Add method". Write the function name and parameter and return type (the internal name can be different from the external name ).
4. after adding the function, you can view the added function under the "C + project name + ctrl" Class in the Class View (the internal name mentioned above is displayed here ), double-click the function to write your own code.

The preceding step adds an external function of the ActiveX control. On the webpage, you can call this function in the JavaScript function. The call method is to run the "Control ID. function Name (parameter) ". The control ID here refers to the ID specified for ActiveX on the webpage, for example, <Object ID =" Control ID "classid =…> </Object>. Function name refers to the external name in step 1 above.

As shown in: three methods are defined: Login, MessageBox, and Test2.

It is worth noting that if you want to pass the javascript string to the control as a parameter, the MFC parameter should be of the BSTR type.

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.