C#的WebBrowser的部分 用法

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
namespace OracleCode
{
    public partial class Form1 : Form
    {
      static  string nameq = "1";
        string htmlname = @"<!DOCTYPE html>
<html>

<head>
    <title>

    </title>
    <style>
        * {
            padding: 0px;
            margin: 0px;

        }

        #d {

            border: red 1px solid;
            background: red;
            width: 600px;
            height: 419px;

        }

        .a {
            float: right;
        }
    </style>
</head>

<body>


   
        <div id = 'd' >
             <div class='a'>
                <input type = 'text' value='"+nameq+@"' width='10' />
            </div>
 <marquee behavior=' aaa' direction='aaa'>"+nameq+@"
    </marquee>
    </div>


</body>

</html>";

        public Form1()
        {
            InitializeComponent();

            WebBrowser webBrowser = new WebBrowser();
            webBrowser.Size = new Size(818, 497);

            webBrowser.ScriptErrorsSuppressed = true;
            webBrowser.ScriptErrorsSuppressed = true;
            webBrowser.IsWebBrowserContextMenuEnabled = false;
            webBrowser.AllowWebBrowserDrop = false;
            webBrowser.WebBrowserShortcutsEnabled = false;
            // webBrowser.Navigate(Application.StartupPath +htmlname);
            webBrowser.DocumentText = htmlname;
            TextBox t = new TextBox();
            t.Name = "te";
            t.Size = new Size(122 * 818, 100);
            t.Location = new Point(10, 122);
            this.Controls.Add(t);
            //this.Opacity = 0.2;
            this.Controls.Add(webBrowser);




        }

        private void Form1_Load(object sender, EventArgs e)
        {

            //s.ScriptErrorsSuppressed = true;//禁止脚本错误

            //s.ScriptErrorsSuppressed = true; //禁用错误脚本提示
            //s.IsWebBrowserContextMenuEnabled = false; // 禁用右键菜单
            //s.WebBrowserShortcutsEnabled = false; //禁用快捷键
            //s.AllowWebBrowserDrop = false; // 禁止文件拖动

            //s.Navigate(Application.StartupPath + @"\assets\index.html");

            //s.Navigated += WebBrowserNavigatedEventHandler;
            //s.DocumentCompleted += WebBrowserDocumentCompletedEventHandler;
            //s.Document.Window.Error += new HtmlElementErrorEventHandler(Window_Error);
            //s.NewWindow += CancelEventHandler;




        }
    }
}

 

;

 


}
}
}

posted @ 2019-03-19 10:47  Y云Cc  阅读(1163)  评论(0编辑  收藏  举报