深圳全飞鸿

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 170|回复: 0
打印 上一主题 下一主题

CefSharp的OnJSDialog

[复制链接]

228

主题

466

帖子

2184

积分

版主

Rank: 7Rank: 7Rank: 7

积分
2184
跳转到指定楼层
楼主
发表于 2024-8-25 14:32:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
public bool OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, JavascriptDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback)
{
    if (dialogType == JavascriptDialogType.Alert)
    {
        // 显示自定义的警告对话框,并获取用户的选择
        var userChoice = ShowCustomAlertDialog(messageText);

        // 根据用户的选择继续对话框处理
        if (userChoice == true)
        {
            callback.Continue(true);
        }
        else
        {
            callback.Continue(false);
        }
    }
    else if (dialogType == JavascriptDialogType.Confirm)
    {
        // 显示自定义的确认对话框,并获取用户的选择
        var userChoice = ShowCustomConfirmDialog(messageText);

        // 根据用户的选择继续对话框处理
        callback.Continue(userChoice);
    }
    else if (dialogType == JavascriptDialogType.Prompt)
    {
        // 显示自定义的提示对话框,并获取用户的输入
        var userInput = ShowCustomPromptDialog(messageText, defaultPromptText);

        // 根据用户的输入继续对话框处理
        callback.Continue(true, userInput);
    }
    else
    {
        // 其他类型的对话框,使用默认处理方式
        return false;
    }

    return true;
}


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|nagomes  

GMT+8, 2025-5-5 01:48 , Processed in 0.027625 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表