1

I have an embedded WebView toWeb that loads a local HTML file.

My alert alert("Some message"); is not fired

The UIDelegate is set on toWeb

I have checked here: JavaScript alert() not working in embedded WebView

and WKUIDelegate Protocol Reference

and came up with

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 {

    }

However I still get no alert fired at all from my embedded WebVieW

Community
  • 1
  • 1
JSA986
  • 5,870
  • 9
  • 45
  • 91

1 Answers1

1

Sorted it

 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 {

             }
JSA986
  • 5,870
  • 9
  • 45
  • 91