Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: iOS JavaScript 桥
我有一个 webview 和一个 UIButton 。我想从本机代码进行 javascript 调用。我怎么能做到这一点。
按照这些链接。 使用 html 按钮调用 javascript 函数
http://devlicio.us/blogs/sergio_pereira/archive/2009/02/09/javascript-5-ways-to-call-a-function.aspx
http://www.webmasterworld.com/javascript/3749371.htm?highlight=msg3753441
这些可能会有所帮助
NSString *param =@"Mango"; [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"JSMethod('%@')", param]];
这可能会帮助您解决您的查询:
[webView stringByEvaluatingJavaScriptFromString:@"myJSFunction()"];