Hi I was wondering if there's anyway when loading a webview in titanium to skip down to a particular portion of a page. I thought it would be called an anchorpoint but that property didn't do anything for me. Could I inject some html or what is the best way to do this. I'll need it for Android and iOS.
Asked
Active
Viewed 635 times
1 Answers
0
Yes, you should include a function at JS code of WebView added.
So, use:
webViewNew.addEventListener('load', function(){
webViewNew.evalJS('functionScroll()');
});
Use this reference for JS code
This code execute function when the webview is loaded (DOM).

Community
- 1
- 1

Alejandro F. Carrera
- 403
- 3
- 3
-
Hi thank you very much for the response. I understood I would have to add some listener to the webview and call a function to do the scrolling, but it's the actual scrolling part I don't know how to do. The code you pointed me to seems to be jQuery, however I am working with Titanium and do not know how to scroll in that environment – user2363025 Aug 12 '14 at 08:34
-
Titanium does not have control over WebView content, so you can not scroll from Titanium Code. You must do scroll from HTML with JavaScript function (jQuery, JavaScript or any) – Alejandro F. Carrera Aug 18 '14 at 09:49
-
but can you not inject html into a webview? I think I did something like this before. But when I inject html, I can't use jQuery within titanium, just regular js. Or at least I think so?? – user2363025 Aug 20 '14 at 10:16
-
something like this: WebView.addEventListener('load', function onLoad(e) { WebView.setHtml('something to set the scroll">'+ originalWebView.html); WebView.reload(); WebView.removeEventListener('load', onLoad); }); – user2363025 Aug 20 '14 at 10:19
-
You should have scroll code in originalWebView.html due to HTML headers and parse HTML code. Example: blablabla... For inject js frameworks or something, you should have all code inside html code, because Titanium think that is a Titanium JS not JS Plain File (bug Android). – Alejandro F. Carrera Aug 20 '14 at 10:21
-
Ok so it's not doable from titanium and I need to request the scroll from the web developer? – user2363025 Aug 20 '14 at 10:26
-
Yes. [An example](http://developer.appcelerator.com/question/46431/detecting-scroll-on-a-webview) – Alejandro F. Carrera Aug 20 '14 at 10:34