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 ));")
Shez ratnani
  • 121
  • 1
  • 11

1 Answers1

0

Try add single quotation marks:

self.myWebView.stringByEvaluatingJavaScript(from: "fillText('\(myVal ?? MyValue )');")
Yun CHEN
  • 6,450
  • 3
  • 30
  • 33