WebBrowser: How to automatically allow activeX content

别说谁变了你拦得住时间么 提交于 2019-12-25 02:24:42

问题


I have a problem where I am opening a set of html files found on the local computer which use ActiveX controls.

The constant notification popup is frustrating as every page it appears.

I cannot change the file as it is generated by an external application and I do not want enable ActiveX controls for IE in general.

What I would like to do is allow my webbrowser control, embedded in a WPF window, to allow blocked content automatically if it is from the local computer (or at the very least any blocked content as I can control what my webbrowser control can and cannot open)

I cannot see any obvious way of doing this, there are no options to allow blocked content and no event for identifying when blocked contetn has been foud.

Is there any way to achieve this?

Thanks

EDIT - There have been plenty of views for this question but not a single comment. I will welcome any suggestions, perhaps even an alternative control, I realise the default WebBrowser is not ideal. Are there any other browsers that do offer this feature?

To add a little detail to the problem I think I should explain the requirements some more:

The resource being displayed is a set of html files that are generated as a report by a legacy tool that cannot be changed. The tool I have built will allow the user to define the destination for the report and then allow them to browse it using an embedded browser. I really just need a control that will render html and ActiveX controls as a browser would but without any interference from internet security settings.


UPDATE - Unfortunately I am no longer working on this project, however I am interested in the problem/fix so I shal try and replicate it in my spare time.

I have also renamed the question as I realise the problem I am dealing with specifically is ActiveX content, which may have a solution (see answer from Rajesh) which is specific to this type of content.


回答1:


You need to add the file location to your trusted sites. This is possible either with a webserver running on your local machine or if the folder where they are located is a shared folder.

In IE, go to Internet Options > Security, select "Trusted Sites" and click the "Sites" button. Enter the location (i.e. file:\server-Hostname\Sharedfolder* for a shared folder) and click "add" (make sure that the "Require server verification (https:)..." option is unchecked).

There is a lot more information available if you search "Add local file to trusted sites" on the web. I do seem to recall adding a local file location without having to share the folder, but at the moment I don't remember how I did it.




回答2:


Simply add this line to your html page at the start before the html tag.

< saved from url=(0023)http://www.contoso.com/

and then select and comment it.



来源:https://stackoverflow.com/questions/21287619/webbrowser-how-to-automatically-allow-activex-content

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!