本地 html 文件 javascript 未显示图表
Local html file with javascript not showing graphs
新来的,如有遗漏请见谅...
我正在尝试在 WebBrowser1 中显示本地 html 文件,其中包含 javascript 从 Internet 检索数据。
不显示图表,仅显示标题。它在 Edge、IE、Firefox 和我电脑上的 Chrome 中运行良好。如果我在互联网上加载网站并登录,就会显示图表。但我必须使用来自本地 html 页面的文件,因为它是为我的目的定制的。我错过了什么?
Imports System.IO
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebBrowser1.ScriptErrorsSuppressed = True
Dim filePath As String
filePath = Application.StartupPath & "\Winningtemp.html"
WebBrowser1.Url = New Uri(filePath)
WebBrowser1.Refresh()
End Sub
HTML-file Winningtemp.html:
<body>
<script type="text/javascript" id="***">
Script follows here... Can't show the code, sorry...
</script>
</body>
我正在使用 Visual Studio Express 2017。
Screenshot
这似乎是由于 WebBrowser Emulation 版本较低所致。
Private Sub sub_WebBrowser_lastVersionEmulation(Optional ByVal IsDefaultVersion As Boolean = False)
'WebBrowser Emulation
Try
Dim VersionCode As Integer
Dim Version As String = ""
Dim ieVersion As Object = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Internet Explorer").GetValue("svcUpdateVersion")
If ieVersion Is Nothing Then
ieVersion = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Internet Explorer").GetValue("Version")
End If
If ieVersion IsNot Nothing Then
Version = ieVersion.ToString.Substring(0, ieVersion.ToString.IndexOf("."c))
Select Case Version
Case "7"
VersionCode = 7000
Case "8"
VersionCode = 8888
Case "9"
VersionCode = 9999
Case "10"
VersionCode = 10001
Case Else
If CInt(Version) >= 11 Then
VersionCode = 11001
Else
Throw New Exception("IE Version not supported")
End If
End Select
Else
Throw New Exception("Registry error")
End If
Dim AppName As String = ""
''AppName = My.Application.Info.AssemblyName
AppName = System.Diagnostics.Process.GetCurrentProcess().ProcessName
Dim sRoot As String = "HKEY_CURRENT_USER\"
Dim sKEY As String = "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION"
If IsDefaultVersion = False Then
'Check if the right emulation is set
'if not, Set Emulation to highest level possible on the user machine
Dim CurrentSetting As String = CStr(Microsoft.Win32.Registry.CurrentUser.OpenSubKey(sKEY).GetValue(AppName & ".exe"))
If CurrentSetting Is Nothing OrElse CInt(CurrentSetting) <> VersionCode Then
Microsoft.Win32.Registry.SetValue(sRoot & sKEY, AppName & ".exe", VersionCode)
Microsoft.Win32.Registry.SetValue(sRoot & sKEY, AppName & ".vshost.exe", VersionCode)
End If
Else
'Default Version
Microsoft.Win32.Registry.SetValue(sRoot & sKEY, AppName & ".exe", 10001)
Microsoft.Win32.Registry.SetValue(sRoot & sKEY, AppName & ".vshost.exe", 10001)
End If
Catch ex As Exception
'skip
End Try
End Sub
新来的,如有遗漏请见谅...
我正在尝试在 WebBrowser1 中显示本地 html 文件,其中包含 javascript 从 Internet 检索数据。 不显示图表,仅显示标题。它在 Edge、IE、Firefox 和我电脑上的 Chrome 中运行良好。如果我在互联网上加载网站并登录,就会显示图表。但我必须使用来自本地 html 页面的文件,因为它是为我的目的定制的。我错过了什么?
Imports System.IO
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebBrowser1.ScriptErrorsSuppressed = True
Dim filePath As String
filePath = Application.StartupPath & "\Winningtemp.html"
WebBrowser1.Url = New Uri(filePath)
WebBrowser1.Refresh()
End Sub
HTML-file Winningtemp.html:
<body>
<script type="text/javascript" id="***">
Script follows here... Can't show the code, sorry...
</script>
</body>
我正在使用 Visual Studio Express 2017。
Screenshot
这似乎是由于 WebBrowser Emulation 版本较低所致。
Private Sub sub_WebBrowser_lastVersionEmulation(Optional ByVal IsDefaultVersion As Boolean = False)
'WebBrowser Emulation
Try
Dim VersionCode As Integer
Dim Version As String = ""
Dim ieVersion As Object = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Internet Explorer").GetValue("svcUpdateVersion")
If ieVersion Is Nothing Then
ieVersion = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Internet Explorer").GetValue("Version")
End If
If ieVersion IsNot Nothing Then
Version = ieVersion.ToString.Substring(0, ieVersion.ToString.IndexOf("."c))
Select Case Version
Case "7"
VersionCode = 7000
Case "8"
VersionCode = 8888
Case "9"
VersionCode = 9999
Case "10"
VersionCode = 10001
Case Else
If CInt(Version) >= 11 Then
VersionCode = 11001
Else
Throw New Exception("IE Version not supported")
End If
End Select
Else
Throw New Exception("Registry error")
End If
Dim AppName As String = ""
''AppName = My.Application.Info.AssemblyName
AppName = System.Diagnostics.Process.GetCurrentProcess().ProcessName
Dim sRoot As String = "HKEY_CURRENT_USER\"
Dim sKEY As String = "Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION"
If IsDefaultVersion = False Then
'Check if the right emulation is set
'if not, Set Emulation to highest level possible on the user machine
Dim CurrentSetting As String = CStr(Microsoft.Win32.Registry.CurrentUser.OpenSubKey(sKEY).GetValue(AppName & ".exe"))
If CurrentSetting Is Nothing OrElse CInt(CurrentSetting) <> VersionCode Then
Microsoft.Win32.Registry.SetValue(sRoot & sKEY, AppName & ".exe", VersionCode)
Microsoft.Win32.Registry.SetValue(sRoot & sKEY, AppName & ".vshost.exe", VersionCode)
End If
Else
'Default Version
Microsoft.Win32.Registry.SetValue(sRoot & sKEY, AppName & ".exe", 10001)
Microsoft.Win32.Registry.SetValue(sRoot & sKEY, AppName & ".vshost.exe", 10001)
End If
Catch ex As Exception
'skip
End Try
End Sub