问题
I have some javascript code that I need to execute from an objective-c (iPhone) app.
The javascript code needs some of the values from the iPhone app. What I mean is, there is a spot in the iPhone app (a textbox
) for a user to type their name. Then the javascript code that runs will be: alert(name)
where the name
variable is really textbox.text
How can I do this from objective-c, without relying on an external webserver?
Thank you!
回答1:
Add a UIWebView
and inject a <script>
tag containing the JavaScript using [webview loadHTMLString: html]
来源:https://stackoverflow.com/questions/7922961/executing-javascript-code-from-objective-c