Javascript 如何确定用户从服务器下载的网页中选择的输入字段
我尝试了以下方法但没有成功,任何帮助都将不胜感激Javascript 如何确定用户从服务器下载的网页中选择的输入字段,javascript,ios,Javascript,Ios,我尝试了以下方法但没有成功,任何帮助都将不胜感激 UIPasteboard *pb = [UIPasteboard generalPasteboard]; [pb setString:passwordName]; NSString *jScriptString; jScriptString = [NSString stringWithFormat:@"var output = {document.getElementById;" " ;output.innerHTML = document
UIPasteboard *pb = [UIPasteboard generalPasteboard];
[pb setString:passwordName];
NSString *jScriptString;
jScriptString = [NSString stringWithFormat:@"var output = {document.getElementById;" " ;output.innerHTML = document.activeElement.value = '%@'}", passwordName];
[self.viewWebSite stringByEvaluatingJavaScriptFromString:jScriptString];
这里只是猜测一下,但是当您uiwebview加载页面时,您可以在ios应用程序中添加一个本地的.js文件,该文件将向dom中找到的每个输入字段添加一个onfocus方法。然后,您可以让onfocus事件通过window.location属性将元素id传递给iOS,webView:shouldStartLoadWithRequest:navigationType:可以监视该属性