WebView Cant显示类似Chrome或Safari的webAlert

时间:2019-03-29 11:04:33

标签: ios swift webview

我正在快速制作WKWebView,但遇到了问题。我可以在chrome浏览器或safari中看到网络警报,但在webview中看不到。我上传了2张图片。有谁可以帮忙吗?

    var webView: WKWebView!
    var popupWebView: WKWebView?

    override func viewDidLoad() {
        super.viewDidLoad()

        setupWebView()

        let myURL = URL(string:"http://*******/LiveGallery/")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)

    }

    func setupWebView() {
        let preferences = WKPreferences()
        preferences.javaScriptEnabled = true
        preferences.javaScriptCanOpenWindowsAutomatically = true
        let configuration = WKWebViewConfiguration()
        configuration.preferences = preferences
        webView = WKWebView(frame: view.bounds, configuration: configuration)
        webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        view.addSubview(webView)
    }

}

Safari https://i.imgur.com/w5wcT6h.png

WebView https://i.imgur.com/OXRPDAd.png

0 个答案:

没有答案