Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-08-2009, 12:24 AM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 1
Default incorrect javascript scrolling with uiwebview

i have several uiwebviews with a considerable amount of text. when making a window.scrollto (as well as a window.scroll) javascript call to the webviews, they scroll to an incorrect location. e.g. i want to scroll to 12000 but the webview will scroll to 10149 every time instead. while another one will scroll to 10250. yet another one, which i want to scroll to 22000 or so, will scroll to 20230 every time instead.

this only happens on the device and not in the simulator.

i am making the call in webViewDidFinishLoad.

i have tried making the call multiple times in a row with no better results. it seems that whatever value the particular webview scrolls to is the farthest it is willing to go when using the scrollto call. there is no problem when giving it a lesser value to scroll to. it's just if you pass that magic number, whatever it is for that webview, it will go no further.

any input would be much appreciated
ilyashev is offline   Reply With Quote
Old 01-22-2010, 03:32 AM   #2 (permalink)
Mobile Application Dev.
 
Join Date: Oct 2008
Location: Bangalore, india
Posts: 362
Default

Quote:
Originally Posted by ilyashev View Post
i have several uiwebviews with a considerable amount of text. when making a window.scrollto (as well as a window.scroll) javascript call to the webviews, they scroll to an incorrect location. e.g. i want to scroll to 12000 but the webview will scroll to 10149 every time instead. while another one will scroll to 10250. yet another one, which i want to scroll to 22000 or so, will scroll to 20230 every time instead.

this only happens on the device and not in the simulator.

i am making the call in webViewDidFinishLoad.

i have tried making the call multiple times in a row with no better results. it seems that whatever value the particular webview scrolls to is the farthest it is willing to go when using the scrollto call. there is no problem when giving it a lesser value to scroll to. it's just if you pass that magic number, whatever it is for that webview, it will go no further.

any input would be much appreciated
Hi,
I am trying to scroll webview to an offset when a button click occurs [Page up and Page down buttons], for that i have to know the following things,

i) Scrollable content height,
ii) How to move the webview to an offset of the screen.

If u have any info , would be appreciated
mpramodjain is offline   Reply With Quote
Old 01-22-2010, 06:02 AM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: India
Posts: 107
Default

Quote:
Originally Posted by ilyashev View Post
i have several uiwebviews with a considerable amount of text. when making a window.scrollto (as well as a window.scroll) javascript call to the webviews, they scroll to an incorrect location. e.g. i want to scroll to 12000 but the webview will scroll to 10149 every time instead. while another one will scroll to 10250. yet another one, which i want to scroll to 22000 or so, will scroll to 20230 every time instead.

this only happens on the device and not in the simulator.

i am making the call in webViewDidFinishLoad.

i have tried making the call multiple times in a row with no better results. it seems that whatever value the particular webview scrolls to is the farthest it is willing to go when using the scrollto call. there is no problem when giving it a lesser value to scroll to. it's just if you pass that magic number, whatever it is for that webview, it will go no further.

any input would be much appreciated
Hi,

I am using following code for save current position.
Code:
[[NSUserDefaults standardUserDefaults] setInteger:[[webStory stringByEvaluatingJavaScriptFromString:@"scrollY"]intValue] forKey:@"currentScroll"];
"webStory" stand for my webView.

And for retrieve it.
Code:
[[NSUserDefaults standardUserDefaults]integerForKey:@"currentScroll"];
This will give you int value.
For Passing value to webView use following,
Code:
[webStory stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.scrollTo(0, %d);",yourIntValue]];

Its working for me.

All The Best
__________________
Thank You,

Last edited by Jindal; 01-22-2010 at 06:05 AM.
Jindal is offline   Reply With Quote
Reply

Bookmarks

Tags
javascript, scrolling, scrollto, uiwebview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 247
21 members and 226 guests
ADY, bookesp, ckgni, dacapo, Dani77, DarkAn, Davey555, Desert Diva, HemiMG, iDifferent, jakerocheleau, JasonR, LEARN2MAKE, nobre84, prchn4christ, Rudy, ryantcb, Speed, themathminister, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,766
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:40 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0