简体   繁体   中英

calling javascript code in C# Windows Phone 7.5 app

I would like to run some JavaScript code in C# to clear localstorage after clicking a button in appbar in a Windows phone 7.5 app. I came across various code through Stack Overflow and forums But the specific code does not work in Windows phone app. Could you help me providing code which works in Windows Phone 7.5 app?

You Just clear the

Cookies and Web Browser Cache

YourWebBrowserControl.ClearCookiesAsync();

YourWebBrowserControl.ClearInternetCacheAsync();

On the WebBrowser control set IsScriptEnabled to true.

In the JavaScript on the loaded page create a function to clear the storage. (For example call it "ClearStorage")

From code behind call this.webBrowser1.InvokeScript("ClearStorage"); . (Adjust the name of the WebBrowser control as appropriate.)

After load the web page, when LoadCompleted event has raised, call InvokeScript. If you do that before, the application throws exception with error code 80020006.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM