Wkwebview do not display the prompt box (Swift)

Source: Internet
Author: User

The use of Wkwebview will appear when you do some of the pages have a prompt box, why use other People's Page prompt box is always not displayed, in fact, a large part of the reason is because the prompt box is called by JS, you need to implement wkuidelegate to monitor

MARK:-wkuidelegate//monitoring via JS call warning box func WebView (_ Webview:wkwebview, runjavascriptalertpanelwithmessage mes Sage:string, Initiatedbyframe frame:wkframeinfo, Completionhandler: @escaping (), Void) {Let alert = Uialer  Tcontroller (Title:nil, Message:message, Preferredstyle:. Alert) Alert.addaction (uialertaction (title: "OK", style: . Default, Handler: {(action) in Completionhandler ()})) Self.present (alert, animated:true, com PLETION:NIL)}//Listen through JS call Prompt box Func WebView (_ Webview:wkwebview, Runjavascriptconfirmpanelwithmessage messag E:string, Initiatedbyframe frame:wkframeinfo, Completionhandler: @escaping (Bool), Void) {Let alert = Uiale Rtcontroller (Title:nil, Message:message, Preferredstyle:. Alert) Alert.addaction (uialertaction (title: "OK", style :. Default, Handler: {(action) in Completionhandler (True)})) Alert.addaction (Uialertaction (titl E: "Cancel", Style:. defAult, Handler: {(action) in Completionhandler (False)})) Self.present (alert, animated:true, com  PLETION:NIL)}//Listen JS call input box func WebView (_ Webview:wkwebview, Runjavascripttextinputpanelwithprompt prompt:        String, defaulttext:string, Initiatedbyframe frame:wkframeinfo, Completionhandler: @escaping (String), Void) { Similar to the above two methods}

It is important to note that Completionhandler must be called, otherwise it will go wrong!

Wkwebview do not display the prompt box (Swift)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.