Welcome Guest Search | Active Topics | Sign In | Register

EO.Webbrowser trying to set localstorage item Options
Arne Van den Eynden
Posted: Wednesday, May 6, 2020 9:48:25 AM
Rank: Newbie
Groups: Member

Joined: 5/6/2020
Posts: 2
So in my windows forms i have a Webcontrol and Webview. What i am trying to achieve is to set a localstorage item in the webbrowser.

My current code is this but it doesnt work:

webView1.QueueScriptCall("localStorage.setItem('token', 'agit');");
webView1.QueueScriptCall("alert(localStorage.getItem('token'));");
eo_support
Posted: Wednesday, May 6, 2020 3:12:53 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

We tested your code with the latest build and it works fine. Note that localStorage is always associated to an "origin". So you won't be able to run the code without an origin. For example, when the WebView has just loaded a blank page (about:blank), you won't be able to use localStorage because this is not a valid origin that can have localStorage. You can also use the DevTools console to see if you can find any error message.

Thanks!
Arne Van den Eynden
Posted: Thursday, May 7, 2020 3:17:05 AM
Rank: Newbie
Groups: Member

Joined: 5/6/2020
Posts: 2
And how can i assign localStorage to an origin?
eo_support
Posted: Thursday, May 7, 2020 7:50:41 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
You do not assign localStorage an origin. The origin is automatically determined by the Url you loaded into the WebView. That's exactly why it's called localStorage. For example, if you load "www.google.com" and set localStorage, then everything you set would be associated to "google.com". Later when you load "www.yahoo.com", the localStorage you previously set for "google.com" won't be visible now since the current origin is "yahoo.com".


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.