MicrosoftEdge / MicrosoftEdge/WebView2Feedback
Javascript stops working after a form submit
@champnic is already working on this.
Since May 9, 2022.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
In my app, I need to prevent page reload after a form submit.
So, I get posted data in my ICoreWebView2WebResourceRequestedEventHandler, and then to prevent reload, I set an empty response like this:
wil::com_ptr<ICoreWebView2Environment> environment;
webview2->get_Environment(&environment);
if (environment)
{
wil::com_ptr<ICoreWebView2WebResourceResponse> response;
environment->CreateWebResourceResponse(
nullptr, 404, L"", L"",
&response);
args->put_Response(response.get());
}
The page is then correctly not reloaded, but I can't execute any javascript anymore, be it using ExecuteScript method or the javascript console.
Weird thing is, all the scripts that I've tried to execute using ExecuteScript are run later when I trigger a new submit in my page. But javascript is still blocked, all new ExecuteScript attempts are enqueued until the next submit...
Am I missing something or is there a bug in webview2?
Environment:
Webview2 1.0.1210.30
Webview2 Runtime 101.0.1210.32
(same issue with previous versions)
MFC app
Visual Studio 2019 16.11.13
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.