IOS Goal C - AutoFill and Execute UIWebView

I was wondering if there is any possible way for me to have a webview that automatically enters values ​​for the text fields on the website and is sent so that the user can simply completely bypass the search (in particular the search forms)? Thus, the user is shown only the result?

Example: http://www.eatwellguide.org/mobile/ I noticed looking at a source that uses javascript.

In any case, I can automatically fill them out and click the "Submit" button, even if the user does not see this page. So, is the web page loading on the results page?

Thanks in advance!

In response to the answer:

Is there any specific place for this code? I put it after I executed the upload request in the webView for the site I listed above, and then after [super viewDidLoad] I entered the code that you specified with the values ​​for the first value and the second value, with the name ofOOInInput, which is "SearchKeyword "," SearchSubmit "is the second and then the form identifier as" frmsAS "? It still does not work. What am I doing wrong? I really tried to execute it when the a button is pressed, it still does not work.

+3
source share
1 answer

Yes, you can use the following javascript to fill out the form and submit it.

//Set the values NSString* firstValue = @"first value here"; NSString* secondValue = @"second value here"; // write javascript code in a string NSString* javaScriptString = @"document.getElementById('nameOfOneInput').value=%@;" "document.getElementById('nameOfAnotherInput').value=%@;" "document.forms['nameOfForm'].submit();"; // insert string values into javascript javaScriptString = [NSString stringWithFormat: javascriptString, firstValue, secondValue]; // run javascript in webview: [webView stringByEvaluatingJavaScriptFromString: javaScriptString]; 

You obviously need to set firstValue and secondValue .

+5
source

Source: https://habr.com/ru/post/1488403/


All Articles