ios - 如何禁用 webView 中的弹出窗口?

标签 ios swift

我在 iOS 手机上展示了一个用于支付的 webView,然后在交易完成后,它会在网页和手机上弹出一条提示消息,提示交易成功。我想在手机中禁用该警报消息。 webView 中有我可以使用的函数吗?

func proceedToWeb(urlAppend:String) {

    let vc = WebContentViewController()
    if var urlStr = incident?.url {
        urlStr.append("?uid=\(UserManager.shared.uid)&q=\(urlAppend)")
        print("urlStr \(urlStr)")
        vc.webURL = URL(string:urlStr)
        vc.formViewController = self
    }

    let nav = NavigationController(rootViewController: vc)
    nav.navigationBar.isHidden = true
    nav.willRotate = false
    nav.hidesBarsWhenKeyboardAppears = false
    self.present(nav, animated: true) {

    }


}

最佳答案

您可以使用 javascript 将帖子消息发送到您的网络并从网络禁用它。

// create javascript code as string
let javascriptSource = "window.post.accept({shouldShowAlert: false})"

// evaluate it on webView
self.webView.evaluateJavaScript(javascriptSource)

您可以找到更多详细信息here

关于ios - 如何禁用 webView 中的弹出窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57781120/

相关文章:

ios - 使用 OpenGL ES 在 iPhone 上渲染到立方体贴图

ios - 使用异步响应协议(protocol)

iphone - google::dense_hash_map 与 std::tr1::unordered_map 相比?

ios - 添加按钮 addsubview uitextfield ios swift

ios - swift IOS : How to download image using NSURLSession and didReciveData?

objective-c - 一个部分的 UITableView 高度

ios - NSDate格式在模拟器上正确,在设备上错误

macos - OS X 上的核心数据轻迁移

ios - Swift 2.1 - 制作宽度相对于文本长度的动态按钮

ios - 如何在iOS中制作一个可以触摸的多部分字符串?