在c# winform 中 使用 webBrowser 控件,修改webBrowser.DocumentText 的值后出现下面的提示该文档已被修改,是否保存修改结果?
是:保存修改结果
否:放弃修改结果
取消:仍打开该文档
(此行为3个按纽:) 是 否 取消 请问怎么才能不让这个提示显示。

解决方案 »

  1.   

    你重写一下关闭事件,把 base.OnClosing(e);引掉试试看呢?
      

  2.   

    同问, 我也没办法,以前在CSDN问过的
      

  3.   

    会不会和IE的设置有关,我用的IE7。
      

  4.   

      private void button1_Click(object sender, EventArgs e)
            {
                this.Show();
                Application.DoEvents();
                
                webBrowser1.ScriptErrorsSuppressed = false;            webBrowser1.DocumentText = "uuuu";
                webBrowser1.ShowSaveAsDialog();
            }
      

  5.   

    我是这样做的
    在窗体中添加 一个webBrowser 一个按钮
    private void Form1_Load(object sender, EventArgs e)
    {
        webBrowser1.DocumentText = string.Empty;
        webBrowser1.Document.ExecCommand("EditMode", false, null);
        webBrowser1.Document.ExecCommand("LiveResize", false, null);
    }private void button2_Click(object sender, EventArgs e)
    {            
       this.webBrowser1.DocumentText = "测试程序";
    }第一次单击按钮时没有提示,webBrowser1 写入“测试程序”
    第二次单击时就出现上面的提示应该是第二次单击时webBrowser1中已经有内容的原因。各位帮忙看看怎么解决。
            
      

  6.   

    问题解决了,加上
    this.webBrowser1.AllowNavigation = false结贴
      

  7.   

    找到问题了设置 DocumentText 之间调用webBrowser1.Document.OpenNew(true);
      

  8.   

    请问为什么我老是在name.InnerText="11111111"这个地方出现“未将对象引用设置到对象的实例”的错误啊?
    请高手们看下,我的源代码如下
    private void button1_Click(object sender, EventArgs e)
            {
                HtmlDocument htmldoc = webBrowser1.Document;
                HtmlElement name = htmldoc.GetElementById("UserName2");
                name.InnerText="11111111";
            }
            private void Form1_Load(object sender, EventArgs e)
            {
                this.webBrowser1.Navigate("http://www.xxxxxx.com");            
            }
    我是新手,如果有错,请大家不要喷啊。