Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

incorrect javascript scrolling with uiwebview

ilyashevilyashev Posts: 1New Users
edited January 2010 in iPhone SDK Development
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
Post edited by ilyashev on

Replies

  • mpramodjainmpramodjain Posts: 362Registered Users
    edited January 2010
    ilyashev wrote: »
    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
  • JindalJindal Posts: 109Registered Users
    edited January 2010
    ilyashev wrote: »
    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.
    [[NSUserDefaults standardUserDefaults] setInteger:[[webStory stringByEvaluatingJavaScriptFromString:@"scrollY"]intValue] forKey:@"currentScroll"];
    

    "webStory" stand for my webView.

    And for retrieve it.
    [[NSUserDefaults standardUserDefaults]integerForKey:@"currentScroll"];
    

    This will give you int value.
    For Passing value to webView use following,
    [webStory stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.scrollTo(0, %d);",yourIntValue]];
    


    Its working for me.

    All The Best
    Thank You,
Sign In or Register to comment.