How to pass a parameter to a local html page in WP7 / WP8?

两盒软妹~` 提交于 2019-12-01 09:27:34

As another workaround you can pass your arguments as location hash parameter (if it is not used)

browser.Navigate(new Uri("www/index.html#p=123&p2=567", UriKind.Relative));

and then in index.html

var args = window.location.hash;

(args = '#p=123&p2=567')

Tested on WP7 (index.html is stored in isolated storage) + WP8 (index.html is loaded directly from XAP)

Sergei Grebnov

As a dirty workaround that just works you can implement this as following:

A. Navigate to the page w/o any parameters

B. Attach arguments passing logic below to one of the following events

WebBrowser.Navigated Event - when successfully navigated

WebBrowser.LoadCompleted Event - occurs after the WebBrowser control has loaded content.

C. Inject arguments to html page using webBrowser.InvokeScript (C#)

webBrowser.InvokeScript("eval", new string[] {"processArgs('someArgs') or any generated/custom script"}); 

or

webBrowser.InvokeScript("processArgs", new string[] {"someArgs"});

where processArgs is defined somewhere in your html file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!