• 使用WebKit.net加载HTML编辑器


    关于webkit.net使用请看这里http://www.cnblogs.com/linyijia/p/4045333.html

    nicedit编辑器请到这里下载http://www.nicedit.com/download.php

    private void Form1_Load(object sender, EventArgs e)
            {
                string url = String.Format(@"file:\{0}niceditindex.html", AppDomain.CurrentDomain.BaseDirectory);
                url = url.Replace("\", "/").Replace(" ","%20");
                webKitBrowser1.Navigate(url);
            }
    

      需要把路径修改一下,空格也要转码

    以nicedit为例,以下是index.html代码,里面新增了两个方法,getData(取值)、setData(赋值)

    <html>
    <head>
    	<title></title>
    </head>
    <body style="padding:0;margin:0">
    <div id="sample">
    <script src="nicEdit.js" type="text/javascript"></script>
    <script type="text/javascript">
    bkLib.onDomLoaded(function() {
    	nic=new nicEditor({fullPanel : true}).panelInstance('area2');
    	ndinstance = nic.nicInstances[0]; 
    });
    		function setData(html) {//设置html
    			ndinstance.setContent(html);
            }
    		function getData(){//获取html
    			return ndinstance.getContent();
    		}
    </script>
    
    <textarea style="1000px;height:740px" id="area2"></textarea>
    
    </div>
    
    
    </body>
    </html>
    

      c#使用代码进行取值和赋值

    赋值(因为InvokeScriptMethod这方法没法带参数,所以改用以下方法):
    webKitBrowser1.StringByEvaluatingJavaScriptFromString("setData('sdfsd')");
    

      

    取值:
    MessageBox.Show(webKitBrowser1.Document.InvokeScriptMethod("getData").ToString()); 
    

      

  • 相关阅读:
    0-1性能测试需求分析
    1-10jmeter关联,正则表达式(待巩固)
    1-9jmeter集合点,并发操作
    1-8.jmeter设置断言(检查点)
    1-6jmeter性能测试基础
    泛型中的协变和逆变
    jsPlumb
    jQuery UI vs Kendo UI & jQuery Mobile vs Kendo UI Mobile
    31天重构
    Visual Studio 小工具
  • 原文地址:https://www.cnblogs.com/shensigzs/p/4181383.html
Copyright © 2020-2023  润新知