我有一个简单的程序,我试图加载kongregate聊天到一个WebBrowser,但它不工作…
当我第一次启动它时,它导航到一个游戏,然后它给我4个Script Error,聊天就停在那里说:“加入房间...”。我不认为这是浏览器设置的问题,因为它可以在internet explorer上工作。我的WebBrowser有什么地方出问题了吗?我已经让它在那里放了几分钟,它仍然不能工作。我已经将suppressScriptErrors设置为true和false,但它仍然不能修复它。
仅供参考:我没有对我的程序做任何不好的事情,比如作弊,垃圾邮件,或者诸如此类的事情,我只是想让网页显示出来,有时我喜欢能够复制一些东西,所以我在它的右边放了几个TextBoxes,这样我就可以把它粘贴到聊天中,如果我不想发布一些东西的话……
发布于 2013-12-17 13:30:17
This文章提供了您的问题的解决方案。默认情况下,Visual Studio中的WebBrowser控件似乎以IE7模式启动。这就是为什么你会在控件中得到javescript错误,而不是在浏览器中。我强烈建议你阅读链接到顶部的那篇文章。幸运的是,有一个解决方案。以下代码摘自对间接解决您的问题的另一个stackoverflow问题的回答。Here就是这个链接,下面是代码。
string installkey = @"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
string entryLabel = Path.GetFileName(Application.ExecutablePath);
System.OperatingSystem osInfo = System.Environment.OSVersion;
string version = osInfo.Version.Major.ToString() + '.' + osInfo.Version.Minor.ToString();
uint editFlag = (uint)((version == "6.2") ? 0x2710 : 0x2328); // 6.2 = Windows 8 and therefore IE10
RegistryKey existingSubKey = Registry.LocalMachine.OpenSubKey(installkey, false); // readonly key
if (existingSubKey == null) {
existingSubKey = Registry.LocalMachine.CreateSubKey(installkey, RegistryKeyPermissionCheck.Default); // readonly key
}
if (existingSubKey.GetValue(entryLabel) == null) {
existingSubKey = Registry.LocalMachine.OpenSubKey(installkey, true); // writable key
existingSubKey.SetValue(entryLabel, unchecked((int)editFlag), RegistryValueKind.DWord);
}另外,我前面提到的文章说,你也应该为你的应用程序创建一个VS主机进程的入口,否则它将不能在调试模式下工作。祝你好运,我希望这能解决你的问题!
https://stackoverflow.com/questions/19777633
复制相似问题