0
votes

The webkit framework allows to run Javascript in a frame. I used that with success, but now want to show error messages from JS in my host application. I know you can directly call obj-c/swift methods from JS (which I use for other purposes), but I thought it would make sense to use the alert() function from JS. For that I set my class to be the UIDelegate on the WebView class and overrode the runJavaScriptAlertPanelWithMessage method.

Unfortunately, I cannot test this because when I use e.g. alert("Test"); in my test script I only get the error:

ReferenceError: Can't find variable: alert

Is alert() not supported in WebKit (which would be strange given the UIDelegate method) or what's the problem here?

1

1 Answers

0
votes

Try this:

window.alert("Test")

Should do the trick.