How to handle beforeunload ?
Posted: Sun Nov 07, 2021 8:41 pm
Hi,
Some websites require you to confirm before exit or load another page. I'm trying to get rid of these type of confirmation dialogs like these :
So here is what i'm doing :
The code above makes the confirmation dialog not appear, but it won't let me load another page ; the browser stays on the page that shows the confirmation.
You can simulate this on any Facebook page :
1 - Navigate to www.Facebook.com and login
2 - Simulate a post on your own page , just write something but do not click on Publish.
3 - Now try to navigate to another page ; Facebook will show a confirmation message and this is the kind i want to supress ; i want the user to be able to naviage wherever he wants without any kind of confirmation.
I also tried to run this code after the page loads :
But no lucky, Facebook stills require confirmation to leave it and navigate to another page.
Some websites require you to confirm before exit or load another page. I'm trying to get rid of these type of confirmation dialogs like these :
So here is what i'm doing :
Code: Select all
procedure TChromium1.onBeforeUnloadDialog(Sender: TObject; const browser: ICefBrowser; const messageText: ustring;
isReload: Boolean; const callback: ICefJsDialogCallback; out Result: Boolean);
begin
Result := true;
end;
You can simulate this on any Facebook page :
1 - Navigate to www.Facebook.com and login
2 - Simulate a post on your own page , just write something but do not click on Publish.
3 - Now try to navigate to another page ; Facebook will show a confirmation message and this is the kind i want to supress ; i want the user to be able to naviage wherever he wants without any kind of confirmation.
I also tried to run this code after the page loads :
Code: Select all
window.onbeforeunload = null;