|
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;
}
|
|