vb.net Webbrowser 控件不显示 Javascript

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23489779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 17:30:58  来源:igfitidea点击:

vb.net Webbrowser Control not displaying Javascript

vb.netwebbrowser-control

提问by user1838222

I have tried this on numerous pc's and are receiving the same error. My webbrowser control isnt displaying javascript or jquery.

我已经在许多个人电脑上尝试过这个,并收到同样的错误。我的 webbrowser 控件不显示 javascript 或 jquery。

Here is a example:

下面是一个例子:

when i visit this url in my browser: https://binarykings.co.uk/traderoom-aspx, it looks great with the charts and prices etc.

当我在浏览器中访问这个 url:https: //binarykings.co.uk/traderoom-aspx 时,图表和价格等看起来很棒。

example: http://i.imgur.com/1Lmq4em.png

示例:http: //i.imgur.com/1Lmq4em.png

same in internet explorer: http://i.imgur.com/3KP864X.png

在 Internet Explorer 中相同:http: //i.imgur.com/3KP864X.png

however in my vb.net webbrowser control it looks like this: http://i.imgur.com/qjme2Yg.jpg

但是在我的 vb.net webbrowser 控件中它看起来像这样:http: //i.imgur.com/qjme2Yg.jpg

What is causing this ? Its not just this site but any other site that has a similar way of displaying things via jquery/javascript.

这是什么原因造成的?它不仅是这个站点,还有任何其他具有类似方式通过 jquery/javascript 显示内容的站点。

I do have script errors suppressed however when i disabled this and clicked yes to the errors manually it still displayed the same empty page.

我确实抑制了脚本错误,但是当我禁用它并手动对错误单击“是”时,它仍然显示相同的空白页面。

Thanks

谢谢

回答by Cody Gray

The WebBrowser control uses the Internet Explorer rendering engine. But by default, for compatibility reasons, it is stuck using the IE 7 rendering engine, even if you have a later version of the browser installed on your computer.

WebBrowser 控件使用 Internet Explorer 呈现引擎。但默认情况下,出于兼容性原因,即使您的计算机上安装了更高版本的浏览器,它也无法使用 IE 7 渲染引擎。

There are a couple of ways to convince it to use a newer version of IE to render the page. One involves editing the registry, while the other involves modifying the web page.

有几种方法可以说服它使用较新版本的 IE 来呈现页面。一个涉及编辑注册表,而另一个涉及修改网页。

In general, it is best to avoid attempts to solve local problems with global solutions like registry edits. There might be another app running on the same machine that uses the WebBrowser control and relieson the behavior of the IE 7 rendering engine. If you go changing global settings, you'll mess up that other app.

通常,最好避免尝试使用全局解决方案(例如注册表编辑)来解决本地问题。可能有另一个应用程序在同一台机器上运行,该应用程序使用 WebBrowser 控件并依赖于 IE 7 渲染引擎的行为。如果你去改变全局设置,你会搞砸其他应用程序。

Therefore, the best solution, if possible, is to edit the web page. This is quite simple, and probably a good idea anyway. All you need to do is add the following code inside of the <head>section:

因此,如果可能,最好的解决方案是编辑网页。这很简单,无论如何可能是个好主意。您需要做的就是在该<head>部分中添加以下代码:

<meta http-equiv="X-UA-Compatible" content="IE=9" >

If you absolutely must use the alternative approach of editing the registry, you'll find the information you need here in the documentation.

如果您绝对必须使用编辑注册表的替代方法,您可以在此处的文档中找到您需要的信息。