Javascript – Scrolling a webpage inside UIWebView

iphonejavascriptobjective cuiwebview

I have a UIWebView and UIButton added as subview to my View. I also have a large webpage displayed inside my UIWebView, is it possible to scroll the webpage by clicking a button on the UIView?

I want to make the webpage scroll untill it reaches the bottom of the document.

The javascript to be used is : window.scrollTo(xPos, yPos);

Is it possible to make a javascript call on the button action which will scroll the web document inside the UIWebView?

Best Answer

You can use that on your UIWebview component:

NSString *yourScript = [NSString stringWithFormat:@"javascript_method();"]; 
NSString* responseJS = [webView stringByEvaluatingJavaScriptFromString:yourScript];