我有從本地html文件加載的webview。我想從目標c傳遞數組到JavaScript函數,順便說一句,我是新來的JavaScript。從目標c傳遞對象到javascript
下面的代碼是負荷的html文件,並調用函數:
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"html" inDirectory:@"javascript"];
NSURL *url=[NSURL fileURLWithPath:htmlFile];
[web_out loadRequest:[NSURLRequest requestWithURL:url]];
NSString * jsCallBack = [NSString stringWithFormat:@"login_info('%@')",arrlog];
[web_out stringByEvaluatingJavaScriptFromString:jsCallBack];
在我的html文件:
function login_info(arr){
alert("arr:- " +arr);
}
警報打印 '不確定'。那麼,我怎樣才能把這個javascript函數的arrlog值呢?
鏈接不可用 –
http://perrymitchell.net/article/communication-between-javascript-ios-using-uiwebview-base64/ –