0

Hello Guys I have an app which loads a web view and i have the data copied in my clipboard. I want to paste it in a text field on the web view. I have a function which does that in my javascript. I used this link's marked answer and it works fine when my pasteboard has an int(ex: 123456). But if I have a string or even a character in between the numbers (ex: 123n456) the javascript function doesn't get called. Here is my code:-

let pb: UIPasteboard = UIPasteboard.general
        let myVal: String? = pb.string
        let MyValue: String = myVal!
        self.myWebView.stringByEvaluatingJavaScript(from: "fillText(\(myVal ?? MyValue ));")

1 Answer 1

0

Try add single quotation marks:

self.myWebView.stringByEvaluatingJavaScript(from: "fillText('\(myVal ?? MyValue )');")
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much @Yun it was a great help. It worked :). Thanks again

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.