Results 1 to 5 of 5

Thread: set innerHTML scrolls window to top?

  1. #1
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question set innerHTML scrolls window to top?

    Hi,

    I'm working on a Java Applciation and would like to include AJAX so that large portions of the screen is dynamically updated without the page refreshing or the user loosing their place.

    The AJAX side of things I have working very well (I'm using the excellent JSRS library). However, when I update the screen it scrolls back to the top of the page.

    We're using IE 6. I'm updating the screen by locating a "div", then setting it's "innerHTML" property.

    Any ideas please? With this scrolling problem, it is rendering the AJAX mechanism useless and (from a usability point of view) we may as well simply submit and refresh the screen as in a normal web application.

    Chris.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    ... huh?
    If it's a Java application, you needn't fiddle around with AJAX: Java has a very nice and perfectly usable java.net.Socket class available.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It's a J2EE Web Application, sorry for the confusion.

  4. #4
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I've fixed it myself anyway. In case anyone else is interested, the issue was that I was using an "a" tag to trigger JSRS:

    <a href="#" onclick="myJSRSFunction(...);">Call JSRS</a>

    A "feature" of IE is that this will scroll the window to the top after clicking!

    The following gets around it:

    <img src="..." onclick="myJSRSFunction(...);"/>

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That's a feature of any browser; because you are linking to a non-existant anchor in the page, it will simply scroll to the top. Try returning false from the onclick event, or using "javascript:void(0);" as the href instead of #.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •