JSA986
JSA986

Reputation: 5936

Javascript alert not showing in embedded WebView OSX

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

Upvotes: 1

Views: 921

Answers (1)

JSA986
JSA986

Reputation: 5936

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 {

             }

Upvotes: 1

Related Questions