Unable to implement JS dialogs

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

Unable to implement JS dialogs

Postby jkman » Tue Jul 07, 2015 7:29 am

I am wanting to disable alert,confirm and promp basically. Have implemented the abstract class CefJSDialogHandler like this:
Code: Select all
    public class CustomJSDialogs: CefJSDialogHandler
    {
        protected override bool OnJSDialog(CefBrowser browser, string originUrl, string acceptLang, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message)
        {
            suppress_message = true;
            callback.Continue(true, "");
            return true;
        }
        protected override bool OnBeforeUnloadDialog(CefBrowser browser, string messageText, bool isReload, CefJSDialogCallback callback)
        {
            callback.Continue(true, "");
            return true;
        }

        protected override void OnResetDialogState(CefBrowser browser)
        {
            return;
        }

        protected override void OnDialogClosed(CefBrowser browser)
        {
            return;
        }
    }


And returned them in CefClient like this:
Code: Select all
protected virtual CefJSDialogHandler GetJSDialogHandler()
        {
            return new CustomJSDialogs();
        }


Yet alerts are still showing. What am I doing wrong please?
jkman
Newbie
 
Posts: 7
Joined: Mon Jul 06, 2015 5:26 pm

Re: Unable to implement JS dialogs

Postby jkman » Wed Jul 08, 2015 6:02 am

The same applies in disabling context menu!

I have created custom handler like this:
Code: Select all
public class ContextMenuHH: CefContextMenuHandler
    {
        protected void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams state, CefMenuModel model)
        {
            model.Dispose();
            model = null;
        }

        protected bool OnContextMenuCommand(CefBrowser browser, CefFrame frame, CefContextMenuParams state, int commandId, CefEventFlags eventFlags)
        {
            return false;
        }

        protected void OnContextMenuDismissed(CefBrowser browser, CefFrame frame)
        {
        }
       
    }


And have put it into CefWebClient inplementation like this:
Code: Select all
protected virtual CefContextMenuHandler GetContextMenuHandler()
        {
            return _contextMenuHandler;
        }


where
Code: Select all
_contextMenuHandler = new ContextMenuHH();


yet it does nothing. Need context menus disabled. Is that possible?
jkman
Newbie
 
Posts: 7
Joined: Mon Jul 06, 2015 5:26 pm

Re: Unable to implement JS dialogs

Postby jkman » Thu Jul 09, 2015 5:13 am

Also application crashes from time to time. Could you have a look please at my cefglue.log if it says something?

Here is cefglue.log:
http://pastebin.com/8CfjXXHy

Thank you very much!

PS: It probably says also something about the js alerts - this line seems interesting to me:
Code: Select all
[0709/103348:FATAL:javascript_dialog_manager.cc(103)] Check failed: !*did_suppress_message.
jkman
Newbie
 
Posts: 7
Joined: Mon Jul 06, 2015 5:26 pm

Re: Unable to implement JS dialogs

Postby jkman » Thu Jul 09, 2015 12:06 pm

After removing my JS implementation the error removed. But I still need to disable JS alerts. Any thoughts?
jkman
Newbie
 
Posts: 7
Joined: Mon Jul 06, 2015 5:26 pm

Re: Unable to implement JS dialogs

Postby magreenblatt » Thu Jul 09, 2015 2:23 pm

In C++ you would implement CefJSDialogHandler to override the default JS dialog implementation.
magreenblatt
Site Admin
 
Posts: 12379
Joined: Fri May 29, 2009 6:57 pm

Re: Unable to implement JS dialogs

Postby rkcef » Thu Apr 22, 2021 7:01 am

magreenblatt wrote:In C++ you would implement CefJSDialogHandler to override the default JS dialog implementation.


I know this is a really old thread but I'm unable to find anything newer that has more detailed information about implementing CefJSDialogHandler in the CefClient Example (it seems like jkman was using it).

Maybe you could elaborate a bit on this topic. I've also created a new thread asking for some help on how to correctly implement CefJSDialogHandler in the cefclient example project -> https://magpcss.org/ceforum/viewtopic.php?f=6&t=18356&p=48783#p48783

Thank you very much :)
rkcef
Techie
 
Posts: 27
Joined: Fri Feb 26, 2021 9:11 am


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 5 guests