[英]JS command() API is not displaying more than 2 lines of messages for WPF solution with CEFSharp V84
enter image description here在此处输入图像描述
<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Events</h1>
<h2>The onclick Event</h2>
<button onclick="myFunction()">Confirm</button>
<script>
function myFunction() {
var message = "You have selected:";
message += "Stmt1 \r\n stmt2 \r\n stmt2";
message += "\r\n";
message += "stmt2stmt2stmt2stmt2stmt2stmt2stmt2stmt2stmt2stmt2stmt2\n";
message += "stmt2stmt2stmt2stmt2stmt2stmt2stmt2stmt2stmt2stmt2stmt2stmt2";
status = confirm(message);
}
</script>
</body>
</html>
Here after 3rd line of the message, it is hidden.Also window size is not increasing to contain full text.在消息的第 3 行之后,它是隐藏的。另外 window 大小没有增加以包含全文。 Same is working fine with IE.同样适用于 IE。
using System.Windows;
namespace CefSharp.Wpf.Example.Handlers
{
public class JsDialogHandler : CefSharp.Handler.JsDialogHandler
{
protected override bool OnJSDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage)
{
var b = (ChromiumWebBrowser)chromiumWebBrowser;
b.Dispatcher.InvokeAsync(() =>
{
if (dialogType == CefJsDialogType.Confirm)
{
var messageBoxResult = MessageBox.Show(messageText, $"A page at {originUrl} says:", MessageBoxButton.YesNo);
callback.Continue(messageBoxResult == MessageBoxResult.Yes);
}
else if(dialogType == CefJsDialogType.Alert)
{
var messageBoxResult = MessageBox.Show(messageText, $"A page at {originUrl} says:", MessageBoxButton.OK);
callback.Continue(messageBoxResult == MessageBoxResult.OK);
}
else if (dialogType == CefJsDialogType.Prompt)
{
var messageBoxResult = PromptDialog.Prompt(messageText, $"A page at {originUrl} says:", defaultPromptText);
callback.Continue(messageBoxResult.Item1, userInput: messageBoxResult.Item2);
}
});
return true;
}
}
}
//Assign your handler to the ChromiumWebBrowser instance
browser.JsDialogHandler = new CefSharp.Wpf.Example.Handlers.JsDialogHandler();
Full example added in commit https://github.com/cefsharp/CefSharp/commit/df8a6086a6bbb79280916c955015a1b58a421ddc提交中添加的完整示例https://github.com/cefsharp/CefSharp/commit/df8a6086a6bbb79280916c955015a1b58a421ddc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.