我试图在UIWebView中将Text设置为textarea。
<textarea class="GFS3D5JBNW" style="padding: 4px;border-radius: 5px;" placeholder="Some placeholder text ..." title="Some Title ..." tabindex="1"></textarea>
我试过的代码
NSString *source = [NSString stringWithFormat:@"var inputFields = document.getElementsByTagName('textarea'); \
for (var i = inputFields.length >>> 0; i--;) { if(inputFields[i].tabindex == '1') inputFields[i].value = '%@';}", text];
[self.mainWebView stringByEvaluatingJavaScriptFromString: source];
或
NSString *source = [NSString stringWithFormat:@"var inputFields = document.getElementsByTagName('textarea').value = '%@';}", text];
[self.mainWebView stringByEvaluatingJavaScriptFromString: source];
但没有成功:-(有没有人暗示过我?
答案 0 :(得分:0)
问题由
解决NSString *source = [NSString stringWithFormat:@"var inputFields = document.getElementsByTagName('textarea'); \
for (var i = inputFields.length >>> 0; i--;) {inputFields[i].value = '%@';}",input];
[self.mainWebView stringByEvaluatingJavaScriptFromString:source];