简体   繁体   中英

IOS WKWebView and UIWebView isn't loading JavaScript Sign Up form while Safari does

In Safari my Sign Up form JavaScript code works fine, but in UIWebView and in WKWebView that form isn't loading.

Here is my Code to review.

import UIKit
import WebKit


class ViewController: UIViewController, WKNavigationDelegate {

@IBOutlet weak var Webview: UIWebView!

var webView: WKWebView!
var websites = ["lampecompany.com", "lampecompany.com"]

override func loadView() {
    webView = WKWebView()
    webView.navigationDelegate = self
    view = webView
}
override func viewDidLoad() {
    super.viewDidLoad()

    let url = URL(string: "https://" + websites[0])!
    webView.load(URLRequest(url: url) as URLRequest)
    webView.allowsBackForwardNavigationGestures = true

}

Main page opens correctly and then Menu -> Apply, on this screen Apply here form doesn't display.

Here are both screenshots attached. Safari and WKWebView.

在此处输入图片说明 在此处输入图片说明

Any help regarding this that my WKWebView start behaving like Safari and open each and everything correctly as Safari browser does.

When I put my website link here in this WKWebView browser then its working. https://github.com/mbarnig/WKWebView

so why not in my code. I used the same code in my app but in vein.

Thank you in Advance!

Your web page Signup form ( iframe ) has SSL issue.

In iOS, If you are loading an http url, then you have to add App Transport Security Settings in your info.plist file.

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>

I found the issue in the following way.

  1. Enable Safari Developer mode Safari-> Preference -> Advanced -> Show Developer option on Menu.
  2. Run your app on simulator and Open Safari browser on your Mac.
  3. Go to Developer menu -> Simulator -> Select your site url.
  4. You will get the console log of your web page.

Please see your web page console log below.

在此处输入图片说明

Error : Failed to load resource: An SSL error has occurred and a secure connection to https://www.lampeplacementservices.com/LampeOptin/LampeOptinReferralForm.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM