开发者

IHTMLTxtRange.execCommand("Copy",false,null) fails due to IE settings

开发者 https://www.devze.com 2022-12-26 18:45 出处:网络
We have a .Net application that is used for editing/rendering customized HTML documents. It is hosted in IE using the AxSHDocVw.AxWebBrowser controls. We proceed with navigating to\"about:blank\" page

We have a .Net application that is used for editing/rendering customized HTML documents. It is hosted in IE using the AxSHDocVw.AxWebBrowser controls. We proceed with navigating to "about:blank" page initially then we ch开发者_如何学运维ange the Document by writing our custom values into it. The problem we are facing is the call to IHTMLTxtRange.execCommand("Copy",false,null) is failing if we don't enable the IE Security Settings in the Internet Security zone (Scripting->Allow Programmatic Access to Clipboard ).

In order to bypass the security setting ,I tried to point to a local html file initially while navigating. But this fails as soon as I modify the Document.

I want to use the IHTMLTxtRange.execCommand("Copy",false,null) command so that I can customize our Copy/Paste operations. Is there any other way I can do this. Please share your ideas inorder to overcome this situation. Thanks. Sriram


Try implement IInternetSecurityManager on your webbrowser control host, handle URLACTION_SCRIPT_PASTE in ProcessUrlAction. Note there is a bug in earlier versions of IE that causes the webbrowser to ignore host's URLACTION_SCRIPT_PASTE handling.


As far as I know, there is no way to do that without user permission. Its a security/privacy loophole to allow access to clipboard, and its natural that browsers are protective about it.

  1. You have already tried out ActiveX, and it doesn't work
  2. With Flash, you can interact with system clipboard - but only if its a part of an event handler. See Flash Player 10 Security.
  3. Javascript doesn't expose a way to access the clipboard.
  4. Not sure about silverlight, but I am guessing it would also restrict access to clipboard.

In short, the user has to explicitly give your application/website permission to access clipboard.

0

精彩评论

暂无评论...
验证码 换一张
取 消