简体   繁体   English

.NET WebBrowser控件JavaScript

[英].NET WebBrowser control javascript

Does anybody know if there is some sort of bug or issue with the webBrowser activex control in .NET applications, in this case the embedded browser loads a web page that depends on javascript to play music previews. 是否有人知道.NET应用程序中的webBrowser activex控件是否存在某种错误或问题,在这种情况下,嵌入式浏览器会加载一个依靠javascript播放音乐预览的网页。 It works once but if you navigate to a new page in the system it stops working. 它只能运行一次,但是如果您导航到系统中的新页面,它将停止工作。

Viewing the same site in just a normal IE browser results in no errors at all (tested on several systems of various types). 仅使用普通的IE浏览器查看同一站点就不会有任何错误(在各种类型的多个系统上进行了测试)。


It happens on several different OS's, XP 32 and 64 bit, Vista, Windows 7. 它发生在几种不同的操作系统(XP 32和64位,Vista,Windows 7)上。

Its also not a java applet, just jQuery and the longtail video player with some JS to bind a preview link to the player. 它也不是Java applet,只是jQuery和带有一些JS的长尾视频播放器,用于将预览链接绑定到播放器。 Im very confused as to why it works sometimes but not others. 我对于为什么有时起作用而不是别人感到困惑。

Its also a large live system and getting lots of complaints. 它也是一个大型直播系统,并引起大量投诉。

Let me tell you this straight up. 让我直接告诉你。 The default rendering engine on the WebBrowser control is fixed to ensure compatibility across all platforms. WebBrowser控件上的默认呈现引擎已修复,以确保跨所有平台的兼容性。

Basically, if your installed browser is IE 7 - IE 9, then the rendering engine used is IE 7.0 only (by default). 基本上,如果您安装的浏览器是IE 7-IE 9,则使用的渲染引擎仅是IE 7.0(默认情况下)。

If, however, your installed IE version is IE 6 or below, then the rendering engine used is IE 4.0, unless of course you set it otherwise. 但是,如果您安装的IE版本是IE 6或更低版本,则所用的渲染引擎是IE 4.0,除非您另行设置。

There is a misconception that WebBrowser control uses whatever is currently installed (current IE version) but this is not true, since they do this to reduce backward compatibility issues. 有一个误解,认为WebBrowser控件使用当前安装的内容(当前IE版本),但事实并非如此,因为这样做是为了减少向后兼容性问题。 You can see (as proof) that this really is your problem by going to http://www.whatsmyuseragent.com in your normal browser, and then going to that website again in your WebBrowser control, you will see that it says MSIE 7.0 :). 通过在常规浏览器中转到http://www.whatsmyuseragent.com ,然后在WebBrowser控件中再次转到该网站,您可以看到(作为证明)这确实是您的问题,您将看到它显示为MSIE 7.0 :)。

I suspect your users (and you) who are on IE 6.0 would be experiencing the problems you've alluded to since their rendering engine being used is IE 4.0 (and IE 7 if they are running anything between IE 7 to IE9). 我怀疑使用IE 6.0的用户(和您)会遇到您提到的问题,因为使用的渲染引擎是IE 4.0(如果在IE 7至IE9之间运行任何内容,则使用IE 7)。 This is really bad, especially if they are on IE 6, you should ask them to upgrade their browser if they are IE 6, then, IE 7.0 will be used regardless. 这确实很糟糕,尤其是如果他们使用IE 6,则应该要求他们升级其浏览器(如果他们是IE 6),那么无论使用IE 7.0,都是如此。

I'm not sure if, when IE 10.0 comes out, the WebBrowser control's default engine will go to 10.0 (if 10.0 is installed on system of course) or if it will remain as IE 7.0 even after IE 10.0 is released, we will have to see once it comes out. 我不确定在IE 10.0发行时,WebBrowser控件的默认引擎是否将变为10.0(如果在系统上当然安装了10.0),或者即使在IE 10.0发行后仍保持为IE 7.0,我们将拥有看到它一旦出来。 However, if we guess based on previous experience, I suspect IE 10.0 will be the last version that uses IE 7.0 rendering engine, and when IE 11 comes out, the default rendering engine will remain as IE 11 for all versions of IE between IE 11 & IE 14. This is just a guess by extrapolating what they've done in the past. 但是,如果我们根据以前的经验进行猜测,我怀疑IE 10.0将是使用IE 7.0渲染引擎的最后一个版本,并且当IE 11推出时,对于IE 11之间的所有版本的IE,默认渲染引擎将仍为IE 11。 &IE14。这只是通过推断他们过去所做的事情而得出的猜测。

You can set the WebBrowser control to use the current installed version of Internet Explorer; 您可以将WebBrowser控件设置为使用当前安装的Internet Explorer版本; if you want more information on how to do this, or how to further fix the rendering engine, let me know and I'll help you out with it. 如果您想了解有关如何执行此操作或进一步修复渲染引擎的更多信息,请告诉我,我们将为您提供帮助。

The web browser control uses the same shell as the installed version of Internet Explorer, but in my experience, the full browser handles things more gracefully. Web浏览器控件使用与安装的Internet Explorer版本相同的外壳程序,但是以我的经验,完整的浏览器可以更优雅地处理事情。

It is worth adding some debug to the JavaScript to see where the problem is - is it because longtail isn't registering as loaded, so no events are binding or is it because of a problem with the events. 值得在JavaScript中添加一些调试功能,以查看问题出在哪里-是因为longtail未注册为已加载,因此没有事件绑定,还是因为事件存在问题。

Which version of .net are you using? 您正在使用哪个版本的.net?

Also which OS? 还有哪个操作系统?

Ive noticed within Vista that Java applets <applet> tags causes catastrophic issues. 我已经在Vista中注意到Java applet <applet>标记会导致灾难性的问题。 I believe this is due to it using Microsoft JVM for its java processing, which happens to be unsupported now. 我相信这是由于它使用Microsoft JVM进行Java处理,而现在恰好不支持它。 This does not occur in XP from what ive seen 从我所看到的XP中不会发生这种情况

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM