Scroll window after new line added dynamically

Posted on 2008-11-06
Last Modified: 2012-05-05
I have a mail script that sends out newsletters.  It's written in ASP VBScript.

The mail script is located inside a do while loop and sends out 1 email at a time (at remote smtp server's request).

Here's what's going on.

Create recordset.

  while not rs.eof
  response.Write "Sending email to " & rs.EmailAddress>
  <<email script goes here>>
  response.Write " - OK"
Insert text on page > " - OK <BR>"


The script works fine, but it's the visuals my client is not happy with.

Every time an email is about to be sent, the text "Sending email to" is displayed, and when it's sent, the text " - OK" is added to the same line and then a line break.

After about 30 or so emails are sent, the new lines that are added disappear below the scroll line and the user has to manually scroll the page to see where they are at.

He wants the page to scroll every time a new email is sent so the last email address is always visible on the page.

Is there a way (maybe using javascript) that can be added before the "rs.movenext" line in the script that would scroll the page to the bottom of the window?

I thought about adding an element under the script and setting the focus to that point, but I can't figure out how to do that inside the ASP script.


Question by:webmasterbiz
    LVL 7

    Expert Comment

    Try this:

    (I couldn't get it to stop scrolling automatically tho)
       <script language="javascript">
       var scrolldelay;
       function pageScroll() {
        	window.scrollBy(0,50); // horizontal and vertical scroll increments
        	scrolldelay = setTimeout('pageScroll()',100); // scrolls every 100 milliseconds
          function stopScroll() {
       <body onload="pageScroll();">
    //Then below the OK lines:
        <a id="stopIt" href="Javascript:stopScroll();">Stop scrolling</a>

    Open in new window

    LVL 1

    Author Comment

    Hi bluV11t

    Do you think there's a way to simply call the pageScroll(); function from within the ASP script (just before rs.movenext) , so that it steps down every time a new line is added to the page?
    LVL 7

    Expert Comment

    If you response.flush() to the browser f.ex. before each rs.movenext I think this could be achieved but it still needs to be javascript and clientside.

    response.Write " - OK<script language="javascript">window.scrollBy(0,50);</script>"

    You don't need any of the previous scripts for this to work.

    On response.flush() take a look at this:
    Quote: Note, however, that you must take special precautions when your output is an HTML table, because many browsers won't render the table until the closing </TABLE> is received.

    LVL 7

    Accepted Solution

    Sorry, some missing quotation-marks

    response.Write " - OK<script language=""javascript"">window.scrollBy(0,50);</script>"
    LVL 1

    Author Closing Comment

    Thanks mate.
    That's exactly what I wanted.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now