从webbrowser控件(IE11)将文本复制到剪贴板

时间:2014-06-25 08:54:50

标签: c# asp.net winforms

我正在尝试从webbrowser控件中复制可见文本。由于我使用的是Windows 8,我只能使用IE11进行测试,这可能就是问题所在。

webBrowser1.ScriptErrorsSuppressed = true;
webBrowser1.Navigate("https://www.google.com");
webBrowser1.DocumentCompleted += (s, args) =>
{
    WebBrowser wbSender = s as WebBrowser;

    if (wbSender != null && wbSender.Document != null && 
        args.Url == wbSender.Document.Url)
    {
        //SelectAll seems to work fine
        wbSender.Document.ExecCommand("SelectAll", false, null);

        wbSender.Document.ExecCommand("Copy", false, null);
        //string text = Clipboard.GetText();
    }

};

我知道类似的代码早先在Windows 7 + IE10中有效。所以我的问题是,这是否与浏览器/操作系统有关,或者我是否遗漏了其他内容。

0 个答案:

没有答案
相关问题