zoukankan      html  css  js  c++  java
  • webBrowser 设置文本框

    private void Form1_Load(object sender, EventArgs e)
            {
                this.webBrowser1.Navigate("http://www.baidu.com");
                this.webBrowser1.ScriptErrorsSuppressed = true;
                //禁用右键菜单
                this.webBrowser1.IsWebBrowserContextMenuEnabled = false;
                //禁用键盘快捷键
                this.webBrowser1.WebBrowserShortcutsEnabled = false;
                //打开IE打印机会话框
                this.webBrowser1.ShowPrintDialog();
                //打开IE的打印预览会话框
                this.webBrowser1.ShowPrintPreviewDialog();
                //打开IE的保存 会话框
                this.webBrowser1.ShowSaveAsDialog();
               
            }

    #region 设置网页字段
            /// <summary>
            /// 设置网页字段
            /// </summary>
            /// <param name="strInput"></param>
            private void SetHtmlElementValue(string strInput)
            {
                try
                {
                    Clipboard.Clear();
                    Clipboard.SetDataObject(strInput);
                    IDataObject elementData = Clipboard.GetDataObject();
                    if (elementData.GetDataPresent(DataFormats.Text))
                    {
                        HtmlElement elem = this.webBrowser1.Document.ActiveElement;
                        elem.SetAttribute("value", strInput);
                    }
                    return;
                }
                catch (Exception ex)
                { }
            }

            #endregion

    private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
            {
                SetHtmlElementValue("aaaaaaaaaaa");
            }

  • 相关阅读:
    前端面试题
    js collection
    javascript变量声明提升(hoisting)
    css3动画
    神奇的meta
    wap站bug小结
    前端collection
    js拾遗
    prototype之初印象
    自定义scrollBottom的值
  • 原文地址:https://www.cnblogs.com/jcgh/p/2013998.html
Copyright © 2011-2022 走看看