|
Rank: Newbie Groups: Member
Joined: 5/25/2018 Posts: 6
|
I am attempting to run a piece of JavaScript for a EoWebBrowser control I have loaded on a form, during the form OnShown() method, that is called after I do a Form.ShowDialog(myForm);
Using EvalScript during this event (before or after base.Show runs) I get an exception error:
Exception: EO.WebBrowser.JSInvokeException: EvalScript failed because script engine is not ready or is shutdown before the script can finish. Please use QueueScriptCall instead of EvalScript to execute JavaScript code in this case.
So I tried using the CanEvalScript property to check if it was safe to run, but it never is set to true at the method, I assume because the Shown is not complete.
Witht that result, I turned to using QueueScriptCall, but I get no effect whatsoever, even after the Show Method executed and exited from. The script is never executed and I dont even get an exception error.
Using a different approach, I called a Refresh() on the Shown event before trying to call EvalScript again. Then I got the following:
EO.WebBrowser.JSInvokeException: EvalScript failed because channel is invalid or not ready.
> Is there a way I can check why "the channel is invalid"? This for the Refresh() case, where I think I have the best possibilities because I have forced the Form to finish loading and show.
> Should I avoid calling EvalScript or QueueScriptCall from the form's OnShown() event? I understand at that point the component is not ready possibly so this might be a limitation.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,344
|
Hi, This will occur when you call EvalScript too early before the WebView has been fully created. However QueueScriptCall should work. If you continue to have problems, please try to isolate the problem into a test project and send the test project to us. See here for more details: https://www.essentialobjects.com/forum/test_project.aspxOnce we have the test project, we will be happy to investigate further. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/25/2018 Posts: 6
|
Test Project has been sent.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,344
|
Hi,
We have looked into the test project you sent to us. The reason is because you called QueueScriptCall too early before the WebView has been initialized. To correctly handle this situation, it would require code changes both from your side and from our side. We will change our side first and then will reply here again when the new build is ready.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/25/2018 Posts: 6
|
Thank you very much for your reply, I will wait for your side then.
[Edit] Do you have by any chance a schedule for build releases or ETA for your next release?
Regards!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,344
|
It should be out next week.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,344
|
Hi,
This is just to let you know that we have posted a new build that should resolve this issue. Please download it from our download page and see how it goes.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/25/2018 Posts: 6
|
Good day,
I installed this today and changed the reference to the relevant components but I am seeing the same problem behavior with the test project I emailed (QueueScriptCall not executing the code. EvalScript crashes when used because of the Webview not ready message). You mentioned code changes would be required on both sides, can you give me any additional information on this? Or if I should be monitoring an additional property, etc.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,344
|
Hello, Sorry we missed the information about the code change on your end. You will need to change the script code to something like the following:
Code: JavaScript
window.onload = function() { your_original_script_code_here };
The reason is because when you call QueueScriptCall before the WebView has been fully initialized, the code will be run as soon as possible, which is too early that document.body is still null. Since in your script code you call document.body.appendChild, this will cause a null reference exception since document.body is still null. Using window.onload will delay the execution thus making it valid. Please feel free to let us know if you still have any questions. Thanks!
|
|