|
Rank: Member Groups: Member
Joined: 4/21/2015 Posts: 14
|
I am using 3.0.112.0 version EO.WebBrowser.WPF in my wpf application. Application has a window with eo:webcontrol/webview. when app starts window is launched with specific URL and javascript object is embedded using QueueScriptCall. All this works fine. Problem arise when url in the same webview is changed. The new page loaded doesn't retain javascript that was was added in the first call. I tried doing in UrlChanged event and that didn't work either. Am I doing something wrong. Here's the code snippet where webview is initialized when window is launched first time webVw.BeforeRequestLoad += new BeforeRequestLoadHandler(this.OnBeforeRequestLoad); RegisterJSFunctions(); // registering c# method to be invoked webVw.QueueScriptCall(GetQueueScript()); // adding javascript string webVw.ScriptCallDone += new ScriptCallDoneHandler(this.OnQueueScriptCallDone); webVw.ConsoleMessage += new ConsoleMessageHandler(this.OnConsoleMessage); webVw.Closed += new EventHandler(this.OnViewClosed); webVw.Url = this.EOWebViewURL;
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
A JavaScript object always lives in the context of a window and a document object. When a page is reloaded, both objects are refreshed, so JavaScript objects never out live a page (this is why there are other things such as cookies). Using a different browser engine, or a different wrapper such as EO.WebBrowser will not change this rule.
One thing you can consider is to set WebView.JSInitCode. This is a piece of JavaScript code that will be called everytime a new page is loaded. Inside your JSInitCode you can run your additional JavaScript code. Because it will be called everytime a new page is loaded, so you can recreate your object this way.
Hope this helps. Please feel free to let us know if you still have any questions.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 4/21/2015 Posts: 14
|
I will try using JSInitCode. It makes sense..but I had been using Awesomium for quite some time JS global variable I created on initialization stayed through out the life of the page no matter refreshed or reloaded.
Do I also need to need to register RegisterJSExtensionFunction again when page is refreshed in existing webview?
|
|
Rank: Member Groups: Member
Joined: 4/21/2015 Posts: 14
|
I was able to figure out ..I don't have to re register JSExtensionFunction on reload and your solution worked..thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Great. Glad to hear that you got it working!
|
|