在WebBrowser控件中从.NET Compact Framework调用JavaScript函数

4
有没有办法通过WebBrowser控件从.NET Compact Framework调用JavaScript函数?

你能实现双向调用吗?在.NET CF中是否可以从Javascript调用C#方法(因为ObjectForScripting在.NET CF中不存在)? - Sumeet
1个回答

4

它使用Navigate()方法。我刚刚用Windows Mobile 5.0 Pocket PC模拟器尝试了一下。

例如:

webBrowser1.DocumentText = @"<html><head>
            <script type='text/javascript'>
                function doIt() {
                    alert('hello again');
                    return 'i did it!';
                }
            </script>
            </head><body>hello!</body></html>";
webBrowser1.Navigate(new Uri("javascript:doIt()"));

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接