WebBrowser控件和查询字符串WP7 [英] Webbrowser control and query string WP7

查看:106
本文介绍了WebBrowser控件和查询字符串WP7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时通讯使用WebBrowser控件启动和浏览在Windows Phone 7模拟器和设备的本地加载一些HTML文件。一切工作正常,直到我们使用的查询字符串的网页导航。 JavaScript的需要读取这些查询字符串,但是当包含查询字符串导航完全失败。导航工作正常,没有查询字符串。

Im using the WebBrowser control to launch and browse some html files loaded locally in the windows phone 7 emulator and device. All works fine until a web page navigation with a query string us used. The javascript needs to read these query strings but the navigation totally fails when the query string is included. The navigation works fine without the query string.

停留在这个林大的时间和倒很AP preciate你的看法。
托尼

Im big time stuck on this and would really appreciate your thoughts. Tony

推荐答案

我也无法找到一个方法来查询字符串传递给本地的HTML文件。 (我复制了HTML文件独立存储,并从那里看到它。)

I too can't find a way to pass a query string to a local HTML file. (I copied the HTML file to Isolated Storage and viewed it from there.)

不过...结果
我可以成功地浏览到本地的HTML文件,并指定一个片段。它甚至工作,如果该片段包括等号(=)和符号(&安培;),所以你可以这样做:

However...
I can successfully navigate to a local HTML file and specify a fragment. And it even works if the fragment includes equals signs (=) and ampersands (&) so you can do this:

webBrowser1.Navigate(new Uri("index.html#123=abc&456=def", UriKind.Relative));

和具有以下获得价值

<html>
<head>
    <script type="text/javascript">
        function onLoad() {
            fs.innerHTML = document.location.href.split("#")[1];
        }
    </script>
</head>
<body onload="onLoad()" >
    <p id="fs" />
</body>
</html>

要在页面上显示如下(在浏览器控件)。

to display the following on the page (in the browser control).

 123=abc&456=def

(很明显,你可以做更适当与必要的JavaScript中的有价值的东西。)

(Obviously you could do something more appropriate with the value in javascript as necessary.)

是的,你可以使用类似的查询字符串fragent。

Yes, you can just use the fragent like the querystring.

这,显然,只要你不需要使用这两种工作正常。

This, obviously, works fine as long as you don't need to use both.

这篇关于WebBrowser控件和查询字符串WP7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆