Results 1 to 6 of 6
  1. #1
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    Location
    San Jose, California, USA
    Posts
    1,061
    Thanks
    0
    Thanked 0 Times in 0 Posts

    force page scroll with JS

    On a pop-up window (with scroll bars) how do I force a page down scroll? <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15> This pop-up contains 'n' tables and I want the user to view the most recent table written. After I write the data table to this window, I need to scroll it down so this table is viewable. I tried .scrollby() but couldn't get it to work.

    The pop-up is created after a Submit button is clicked. The subsequent code validates the form input and performs a bunch of math then creates a table for displaying the output. If the user doesn't close this pop-up window before hitting Submit again, they get a 2nd (and 3rd, etc.) table to view. This is preferred since they can see multiple iterations of their input data in the same window. I'd like to make it even nicer by automatically scrolling this newest table into view. <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

    Thnx,
    Deb

  2. #2
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: force page scroll with JS

    Could you use a bookmark at the bottom of the page?

  3. #3
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    Location
    San Jose, California, USA
    Posts
    1,061
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: force page scroll with JS

    Yes I thought of the bookmark idea (add a <a href> thingy) but how do I force the link to execute when the page is loaded? <img src=/S/sneaky.gif border=0 alt=sneaky width=15 height=15> I'm sure the .scrollTo or .scrollBy will work but I can't find samples that show me how to put it all together (I need to somehow know how many pixels to move down which, of course, changes w/resolution).

    Deb

  4. #4
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: force page scroll with JS

    Two stab-in-the-dark (and uneducated!) guesses come to mind:

    1] If the new information is at the bottom, would it matter if the window scrolled all the way to the very bottom? If not, could you put in a scrollby value far greater than it would ever be?

    2] What about ScrollIntoView?

  5. #5
    5 Star Lounger jujuraf's Avatar
    Join Date
    Jun 2001
    Location
    San Jose, California, USA
    Posts
    1,061
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: force page scroll with JS

    Yes, that sounds right and I just now tried it but it didn't seem to work (and yes I do want the last table to show but it does't seem to do that on its own). The top table (first one to be displayed) still shows and nothing scrolled. I must be putting the call in the wrong area. I have this (actual data/names removed):
    <pre>var outW = window.open("", "newWin", "height=375, width=500 scrollbars=1");
    outW.focus();
    outW.document.write("<html>");
    outW.document.write("<title>blah blah blah</title>");
    outW.document.write("<body>");
    outW.document.write("<form><table width='85%' border='0' cellspacing='2'>");
    outW.document.write("<tr><td>Title 1 </td><td>" + x1 + "</td></tr>");
    outW.document.write("<tr><td>Title 2:</td><td>" + x2 + "%</td></tr>");
    outW.document.write("<tr><td>Title 3:</td><td>" + x3 + "</td></tr>");
    outW.document.write("<tr><td>

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: force page scroll with JS

    This is suspiciously reminiscent of the similarly dysfunctional ScrollIntoView method in Word. That's not to say it can't be made to work...

    According to my JS book, you need to specify a more specific element, such as a tag, in order to get this to work. For example, you could set an object variable to that table (either using a collection or by adding an ID="XYZ" to your table tag), and then:

    myTable.scrollIntoView(true);

    to set the top of the table at the top of the top of the window. It would make sense to do this last.

    (I haven't actually tested this........)

Posting Permissions

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