惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
人人都是产品经理
人人都是产品经理
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 【当耐特】
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
博客园 - 叶小钗
罗磊的独立博客
宝玉的分享
宝玉的分享
月光博客
月光博客
V
V2EX
博客园 - 司徒正美
Vercel News
Vercel News
量子位
Y
Y Combinator Blog
美团技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Tailwind CSS Blog
博客园 - Franky
小众软件
小众软件
I
InfoQ
A
About on SuperTechFans

博客园 - 禹过天晴

TextControl技术互助 博文阅读密码验证 - 博客园 (转)不通过web.config在运行时注册httpmodules (学)如何在Oracle中一次执行多条sql语句 (学)条件性唯一性索引的建议 阿里云服务器IIS启用HTTPS协议(转) (学)递归查找窗体中全部控件 博文阅读密码验证 - 博客园 如何让Oracle表及字段显示为区分大小写(转) (转)SQL Server 列转行 博文阅读密码验证 - 博客园 (转)基于SQL的EAN13、ENA8条形码校验位生成 博文阅读密码验证 - 博客园 (原)将Oracle迁移到SQLServer (转)Sql Server 快速查看表结构(表描述及字段说明) 博文阅读密码验证 - 博客园 (转)SQL查询案例:多行转换为一行 (转)找回vss超级管理员密码 (转)SqlServer里DateTime转字符串
(原)用WebBrowser浏览Office Web Apps Server,除去“下载”按钮
禹过天晴 · 2018-01-05 · via 博客园 - 禹过天晴

对,没错,如果你按关键字找到这篇随笔了,相信一定知道背景,以及我所说的是什么。


上一段子代码。

private void timerHideButton_Tick(object sender, EventArgs e)
        {
            try
            {
                HtmlDocument htmlDoc = webBrowser.Document;
                if (webBrowser.Document != null) 
                    htmlDoc = webBrowser.Document.Window.Frames["wacframe"].Document;
                if (htmlDoc == null)
                    return;

                var toolBar = htmlDoc.GetElementById("PptUpperToolbar.LeftButtonDock");    //PPT、PPTX
                if (toolBar == null)      
                    toolBar = htmlDoc.GetElementById("stripLeft");                 //DOC、DOCX、PDF
                if (toolBar == null)
                    toolBar = htmlDoc.GetElementById("m_excelWebRenderer_ewaCtl_stripLeft"); //XLS、XLSX

                if (toolBar != null)
                {
                    toolBar.InnerHtml = "";
                    timerHideButton.Enabled = false;
                }
            }
            catch (Exception ex)
            {
               Console.WriteLine(ex.Message);
            }
        }

  张三问了:还用个Timer,不科学,你应该把代码放到
                         webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e);

       回答:原先我也是这么想的,但是、可是因为 iframe 的原因,Completed事件可能会被激活多次,并且直到最后一次也不能准确得到预期结果。