深圳全飞鸿
标题:
CefSharp的OnJSDialog
[打印本页]
作者:
syant
时间:
2024-8-25 14:32
标题:
CefSharp的OnJSDialog
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;
}
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2