我有一个嵌入的 WebView
toWeb
加载本地 HTML
文件。
我的警报 alert("Some message");
没有触发
UIDelegate 在 toWeb
上设置
我在这里检查过: JavaScript alert() not working in embedded WebView
和WKUIDelegate Protocol Reference
想出了
func toWeb(sender: WebView!, runJavaScriptAlertPanelWithMessage message: String!) {
let myPopup:NSAlert = NSAlert()
myPopup.addButtonWithTitle("OK")
myPopup.messageText = "An alert";
myPopup.informativeText = "Message"
if myPopup.runModal() == NSAlertFirstButtonReturn {
}
但是,我的嵌入式 WebVieW
最佳答案
排序
override func webView(sender: WebView!, runJavaScriptAlertPanelWithMessage
message: String!, initiatedByFrame frame: WebFrame!) {
println("Alert sent")
let myPopup:NSAlert = NSAlert()
myPopup.addButtonWithTitle("OK")
myPopup.messageText = "Title";
myPopup.informativeText = "Message"
if myPopup.runModal() == NSAlertFirstButtonReturn {
}
关于嵌入式 WebView OSX 中未显示 Javascript 警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27741872/