How to ignore the javascript confirm warning?

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

How to ignore the javascript confirm warning?

Postby atai » Fri Feb 14, 2014 4:05 am

HI Marshall,
When trying to close a page than open new page (or just loadURL(new url)) , the cef will warn this msg: "Is it OK to leave/reload this page?"
How can we passby this warning without rebuilding the libcef ( as I know this warning is located in libcef)?
IS it right if I try to override the CefJSDialogHandler?
Thanks,
atai
Techie
 
Posts: 22
Joined: Fri Jan 24, 2014 9:47 pm

Re: How to ignore the javascript confirm warning?

Postby Czarek » Fri Feb 14, 2014 5:07 am

See CefJSDialogHandler::OnBeforeUnloadDialog().

Also see comments in CefLifeSpanHandler::DoClose() - OnBeforeUnloadDialog is mentioned there:
https://code.google.com/p/chromiumembed ... r=r1627#92
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: How to ignore the javascript confirm warning?

Postby atai » Fri Feb 14, 2014 12:18 pm

Thanks Czarek,
I found the solution. It seems simple. Just call:
g_handler->GetBrowser()->GetHost()->CloseBrowser(true);
before loadURL(...)
atai
Techie
 
Posts: 22
Joined: Fri Jan 24, 2014 9:47 pm

Re: How to ignore the javascript confirm warning?

Postby michaeladamkatz » Mon Mar 19, 2018 2:31 am

atai, thanks for posting your solution to call CloseBrowser( true ).

I was not able to find a solution based on OnBeforeUnloadDialog(). I was getting this warning when quitting the program and calling CloseBrowser( false ). I was not able to see OnBeforeUnloadDialog() getting called during that sequence. Changing to CloseBrowser( true ) fixed the problem.

Also, strangely, I was only getting the warning sometimes. If I did certain things during a run, like clicking on certain parts of the screen, it would give the warning when I called CloseBrowser(). But if I didn't do those things, I wouldn't get the warning. So I don't know what criteria CEF was using to decide whether to show the message. I also couldn't find the text of the message anywhere in the source code, so I guess it must be buried in libcef.dll?

(Googling for the text of this message, it looks like others are having the same problem. For instance, some Steam users are complaining about seeing it.)
michaeladamkatz
Mentor
 
Posts: 50
Joined: Wed Jan 09, 2013 5:10 pm


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 30 guests