zoukankan      html  css  js  c++  java
  • (原)用WebBrowser浏览Office Web Apps Server,除去“下载”按钮

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


    上一段子代码。

    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事件可能会被激活多次,并且直到最后一次也不能准确得到预期结果。

  • 相关阅读:
    three.js
    three.js
    three.js
    反射API提供的常用类和函数
    PHP控制反转(IOC)和依赖注入(DI)
    优化思路以及优化过程
    nginx的缓存设置提高性能
    网页内容的压缩编码与传输速度优化
    nginx日志按日期自动切割脚本
    mysql数据备份
  • 原文地址:https://www.cnblogs.com/spymaster/p/8204757.html
Copyright © 2011-2022 走看看