1

Facing issue in PWA. I am trying to display image in WKWebview in iOS using HTML, Javascript.

Example: I have added below file in xCode project and configuring with WKWebview.

in .html

<img id="myimage" onclick="changeImage()" src="http://res.cloudinary.com/klipfolio/image/upload/v1500283193/pic_bulboff_to4zaq.png"  height="180">
    <p>Click the lightbulb to turn on/off the light</p>

in .js file (JavaScript)

window.changeImage = function() {
    element=document.getElementById('myimage');
    if (element.src.match("bulbon")) {
        element.src="http://res.cloudinary.com/klipfolio/image/upload/v1500283193/pic_bulboff_to4zaq.png";
    }
    else { element.src="http://res.cloudinary.com/klipfolio/image/upload/v1500283189/pic_bulbon_tvpcg5.png";
    }
}

But, not displaying image in Webview. showing white box only..

Thanks in advance!

9
  • I suspect HTTP is not allowed in your info.plist. you might want to try it with HTTPS as the cloudinary.com has a valid https certificate Commented Aug 20, 2019 at 5:42
  • Try loading WKWebView with following url jsfiddle.net/Lz9go1q0/1 Commented Aug 20, 2019 at 5:46
  • @SahilManchandaThanks Sahil. After using https also it is not working in WKWebview Commented Aug 20, 2019 at 5:50
  • I'm glad this works for you. Commented Aug 20, 2019 at 5:53
  • @SahilManchanda I'm not able to update the image on click event Commented Aug 20, 2019 at 5:56

1 Answer 1

0

The issue is related to HTTP resources. By default HTTP is disabled. There are two ways you can make it work.

A) By enabling HTTP (Discouraged)

B) By using a valid SSL

Since the image resource already has a valid SSL certificate, changing from HTTP to HTTPS will do the trick.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.