Option Explicit On Option Strict On Imports System.IO Imports Microsoft.Win32 Public Class Form1 Private WithEvents WebBrowser As New WebBrowser With {.Dock = DockStyle.Fill} Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load BrowserEmulation.CreateRenderingModeRegkey(BrowserEmulation.Emulation.IE11Edge) Me.Controls.Add(Me.WebBrowser) Me.WebBrowser.Navigate("https://www.yahoo.co.jp/") End Sub Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing BrowserEmulation.DeleteRenderingModeRegkey() End Sub Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser.DocumentCompleted Dim Document As HtmlDocument = DirectCast(sender, WebBrowser).Document If e.Url.Equals(Document.Url) Then Dim InputBox As HtmlElement = Document.GetElementById("srchtxt") AddHandler InputBox.MouseEnter, AddressOf InputBox_MouseEnter End If End Sub Private Sub InputBox_MouseEnter(ByVal sender As Object, ByVal e As HtmlElementEventArgs) MessageBox.Show("InputBoxのMouseEnterイベント発生", "イベント発生", MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub End Class Public Class BrowserEmulation Public Enum Emulation IE11Edge = 11001 IE11 = 11000 IE10Std = 10001 IE10 = 10000 IE9Std = 9999 IE9 = 9000 IE8Std = 8888 IE8 = 8000 IE7 = 7000 End Enum Private Const FEATURE_BROWSER_EMULATION As String = "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION" Public Shared Sub CreateRenderingModeRegkey(EmulationMode As Emulation) Using Regkey As RegistryKey = Registry.CurrentUser.CreateSubKey(FEATURE_BROWSER_EMULATION) Regkey.SetValue(GetReleaseBuildName, EmulationMode, RegistryValueKind.DWord) Regkey.SetValue(GetDebugBuildName, EmulationMode, RegistryValueKind.DWord) End Using End Sub Public Shared Sub DeleteRenderingModeRegkey() Using Regkey As RegistryKey = Registry.CurrentUser.CreateSubKey(FEATURE_BROWSER_EMULATION) Regkey.DeleteValue(GetReleaseBuildName) Regkey.DeleteValue(GetDebugBuildName) End Using End Sub Private Shared Function GetReleaseBuildName() As String Return Path.GetFileName(Application.ExecutablePath) End Function Private Shared Function GetDebugBuildName() As String Return GetReleaseBuildName.Replace(".exe", ".svhost.exe") End Function End Class