我有一个嵌入式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
答案 0 :(得分:1)
对其进行排序
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 {
}