0

I am trying to load html string with swift parameters but it is not loading

let htmlStr = """
<!DOCTYPE html>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src= "'\(jsUrl)'" id="xxxxx"
        data-error="ErrorCallback" data-cancel="CancelCallback" data-complete="CompleteCallback"
        data-timeout="TimeoutCallback">

    </script>

</head>

<body>
    <div style="clear: both;height: 3px;">
    </div>
</body>


<script type="text/javascript">
    CheckoutConfigure();
    Checkout.showLightbox();
    function CancelCallback() {
        AndroidFunction.cancelCallback()
    }

    function ErrorCallback(response) {
        AndroidFunction.errorCallback(JSON.stringify(response))
    }

    function CompleteCallback(response,sessionVersion) {
        AndroidFunction.completeCallback(response, sessionVersion)
    }

    function TimeoutCallback() {
        AndroidFunction.timeoutCallback()
    }

    
</script>

</html>
"""

Here is calling function

webView.loadHTMLString(htmlStr, baseURL: nil)
6
  • 1
    What does "it is not loading" mean? Commented Apr 27, 2021 at 22:22
  • I see blank webview.@matt Commented Apr 27, 2021 at 22:23
  • Why would it be non-blank? Commented Apr 27, 2021 at 22:27
  • @matt same code in android is loading in webview Commented Apr 27, 2021 at 22:39
  • This HTML file results in a blank webpage even in Safari & Chrome. Commented Apr 27, 2021 at 23:16

2 Answers 2

2

You are making invalid HTML and JavaScript with your phrases like id: "'\(orderId)'". Suppose orderId is 7. Now we have

id: "'7'"

Really? With two sets of quote delimiters? That's not valid JavaScript.

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

1 Comment

You know javascript? If you wrote a book I would buy it
0

Need to connect each paragraph with "\n" in your script. Like this : "" + "\n" ""

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.