Develop Internet Explorer extensions
Create an Internet Explorer 11 add-on
-
Create a class library project (C#, .Net Framework 4.6.1) in Visual Studio.
-
Add references to Interop.SHDocVw and Microsoft.mshtml.
-
Create the following files:
- IEAddon.cs
- Interop.cs
- A form containing a text box and an OK button.
-
In IEAddon.cs:
- Implement IObjectWithSite and IOleCommandTarget interfaces.
- Handle document completion events to highlight specific text in a web page.
- Add registry functions to manage add-in settings and registration.
-
In Interop.cs:
- Define the COM interface used by the add-in.
-
In form:
- Create a property to get/set the text to highlight.
-
In project properties:
- Sign the assembly with a strong key.
- Set "Start external program" to iexplore.exe.
- Set the "Post-build event command line" to register the BHO (including manual registration using regasm and gacutil).
How add-ons work
- Traverse the DOM tree, replacing the specified text with the highlighted version.
- Adds a JavaScript function to your web page that executes when highlighted text is clicked.
- Store configuration settings in the Windows registry.
Creating an Internet Explorer 8 add-on
-
Project setup: Similar to IE11 add-in, using Visual Studio 2010 and .Net Framework 4.
-
File: Same as the IE11 add-in, but uncomment a line in IEAddon.cs to prevent multiple executions.
-
Project properties:
- Use gacutil.exe and RegAsm.exe for 64-bit systems.
Notes on 64-bit IE:
- Use a 64-bit compiler and registration tool (e.g. RegAsm.exe from Framework64).
The above is the detailed content of How to Develop Internet Explorer Extensions for IE8 and IE11?. For more information, please follow other related articles on the PHP Chinese website!