关于WebBrowser 读取 JS数据问题 ??


    <script type="text/javascript">
        var s = selects;
        var a = document.getElementById('futures_exchange');
        var b = document.getElementById('futures_variety');
        var c = document.getElementById('futures_contract');
        s.bind(b, cv);
        s.bind(c, cc);
        s.parent(a, b);
        s.parent(b, c);
        s.selected(a, { value: exchange });
        s.selected(b, { value: variety });
        if (c[1] == undefined || contract != "") {
            s.selected(c, { value: contract });
        } else {
            s.selected(c, { value: c[1].value });
        }
        s._addEvent(a, "change", function () {
            var exValue = a[a.selectedIndex].value; exValue
            if (exValue == "069001005") {

            } else if (exValue == "069001007") {

            } else if (exValue == "069001008") {

            }
            document.getElementById("inputDate").value = date;
        });

        // 跳转页面
        function gotoJcgc(obj) {
            window.location.href = obj.getAttribute("value") + "?ex=" + a[a.selectedIndex].value + "&va=" + b[b.selectedIndex].value + "&ct=" + c[c.selectedIndex].value;
        }

        // 查询事件
        function searchData(blOnload) {
            document.getElementById("PageNav").style.display = "none";
            var dataUrl = "http://datainterface.eastmoney.com/EM_DataCenter/JS.aspx?type=QHCC&sty=QHSYCC&stat=3&fd=" + document.getElementById('inputDate').value + "&mkt=" + a[a.selectedIndex].value + "&code=" + c[c.selectedIndex].value + "&sc=" + b[b.selectedIndex].value;
            FuturesJS.getData(dataUrl, "qhlhList", blOnload, date);
        }

        window.onload = function () {
            document.getElementById("inputDate").value = date;
            // 编辑查询条件并获取数据
            searchData(true);
        }        

    </script>

请问我用delphi 或C#怎样写才能得到返回的data数据???

写一个网页,把你的这些内容拷贝进去。保存为 1.html
用 webBrowser1.Navigate("路径\1.html");
dynamic doc = webBrowser1.Document;
string 值 = doc.getElementById("inputDate").value.ToString();

使用C#和js的互操作就可以
1.设置你Form的ComVisible特性为true 即: [System.Runtime.InteropServices.ComVisibleAttribute(true)]
2.设置webBrowser的ObjectForScripting为当前Form 即:webBrowser.ObjectForScripting = this
3.编写你C#脚本里获取数据的GetData(string dateStr)方法 注意这个方法一定要用public来修饰
4.在你的js里面调用这个方法 即:
// 查询事件
function searchData(blOnload) {
......
......
......
FuturesJS.getData(dataUrl, "qhlhList", blOnload, date);//这个是你获取date的方法
//比如你把获取的结果保存在了date这个变量里
GetData(date);//在这里调用这个方法C#脚本里的这个函数被执行,然后这个date就是js返回的数据
}