[英]Stop the auto resize of the uiwebview web content when focus on input field
[英]Auto focus text field in UIWebview
我正在我的iOS應用程序中加載Webview表單,並且想在表單上自動設置文本字段的焦點。 我試過了
NSString *focus = [NSString stringWithFormat:@"document.getElementsByName('j_captcha')[0].focus()"];
[self.webView stringByEvaluatingJavaScriptFromString: focus];
但這似乎不起作用。 “ j_captcha”是文本字段的名稱。 我該如何實現?
這對我有用
NSString *evalStr = [NSString stringWithFormat:@"setTimeout( function(){document.getElementsByName('j_captcha')[0].focus();},1000);"];
[webView stringByEvaluatingJavaScriptFromString:evalStr];
這篇文章有所幫助-https: //stackoverflow.com/a/14268931/653978
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.