#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    New Jersey
    Posts
    1
    Rep Power
    0

    Javascript/DHTML problem in IE 6...


    Hello,

    I have a survey made up in DHTML/Javascript that scrolls to the bottom of the screen each time another question needs to be asked...it's DHTML, and each time a question is asked the next layer gets displayed and the screen just scrolls down to the question

    ...in IE 5.0 it works fine, but in IE 6.0 it refreshs to the top of the page and has to scroll all through the visable questions each time a new one gets displayed....

    The script is very simple:

    <SCRIPT Language="JavaScript">
    <!-- Hide from old browsers


    function scrollit() {
    for (I=1; I<=3000; I++){
    window.scroll(1,I)
    }
    }
    //-->
    </SCRIPT>

    On each question's possible answer I have a onclick="scrollit();" event.

    Anyone know how I can prevent the page from refreshing like that??

    Appreciate any help.

    Frank
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Try using window.scrollTo( 0, 3000 ); Maybe that will make a difference? It's simpler, at least.
  4. #3
  5. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    Generally when a page refreshes to the top, it's because you're doing something like this:

    <a href="#" onclick="scrollit();">

    After the onclick is run, the url (#) is loaded; since an unassigned anchor - hash mark - means 'top of page', that's where you'll go. The fix:

    <a href="#" onclick="scrollit();return false;">

    This should happen (the refresh) after the scroll, however, not before, so, could be unrelated. If so - might try posting more details about how you're handling this (DHTML, etc.).

IMN logo majestic logo threadwatch logo seochat tools logo