Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Move to the end of an unbuffered CGI web page?

by C_T (Scribe)
on Jan 04, 2005 at 16:28 UTC ( [id://419287]=perlquestion: print w/replies, xml ) Need Help??

C_T has asked for the wisdom of the Perl Monks concerning the following question:

I have a CGI script that's generating a lengthy HTML page using the unbuffered mode ($|=1).

Is there a way to tell the browser to keep following the end of the page so that the user doesn't have to keep scrolling down to see the newest content?

I've looked online for something like this, but the only solution I've found involves #name tags, which won't work for this application.

Thanks for any advice.

CT

Charles Thomas
Madison, WI
  • Comment on Move to the end of an unbuffered CGI web page?

Replies are listed 'Best First'.
Re: Move to the end of an unbuffered CGI web page?
by TedYoung (Deacon) on Jan 04, 2005 at 16:31 UTC

    If it helps any, this isn't really a CGI issue. You won't have cotrol over the user's browser's scrolling. You may want to investigate ways of using JavaScript/DHTM to do this.

    Ted Young

    ($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
Re: Move to the end of an unbuffered CGI web page?
by ikegami (Patriarch) on Jan 04, 2005 at 17:00 UTC
      The javascript method worked like a charm. I just threw out the following to the browser:

      #===== Scroll to the end of the script print "<script>window.scrollTo(0,250000)</script>\n";
      CT
      Charles Thomas
      Madison, WI
Re: Move to the end of an unbuffered CGI web page?
by Grygonos (Chaplain) on Jan 04, 2005 at 16:33 UTC

    If you're wanting to control the client's browser on their machine it sounds like client side scripting ala Javascript rather than something you would do with Perl?

      I was hoping there was some sort of magical HTML tag I could spew out that would make this happen (like the target=_blank tag to make the browser open a new window).

      Thanks for the advice. I'll look into Javascript.

      CT

      Charles Thomas
      Madison, WI
Re: Move to the end of an unbuffered CGI web page?
by revdiablo (Prior) on Jan 04, 2005 at 18:24 UTC
    Is there a way to tell the browser to keep following the end of the page so that the user doesn't have to keep scrolling down to see the newest content?

    Others have commented on this question directly, but I thought perhaps you might like to hear a different approach. Instead of printing the "newest content" at the bottom, you could print it at the top. Then you could set up your page to refresh automatically every X seconds, with HTTP-Refresh. This way, though the newest content might not be as new as it would be if it were continually updated, at least it's convenient to view. Happily, the details are nicely explained in merlyn's column, Watching long processes through CGI, so I don't have to. :-)

Re: Move to the end of an unbuffered CGI web page?
by sgifford (Prior) on Jan 04, 2005 at 18:29 UTC
    I use this JavaScript code for CGIBurn:
    <script> <!--//hide from old browsers ID=window.setTimeout("JumpToBottom();",1000); function JumpToBottom() { window.scroll(0,100000); ID=window.setTimeout("JumpToBottom();",1000); } //--> </script>
Re: Move to the end of an unbuffered CGI web page?
by saskaqueer (Friar) on Jan 05, 2005 at 03:29 UTC

    Everybody seems to be providing you with methods that just jump right to the end constantly -- via scrollTo() or scroll(). scrollBy() can make things a little more smooth if the content isn't streamed out at a racing speed. You can change the scrollBy value and/or the setInterval interval to make it scroll at just the right pace:

    #!perl -w use strict; use CGI; use Time::HiRes qw(sleep); my $q = CGI->new(); print $q->header(), <<'END_HTML'; <html> <head> <title>foobar</title> </head> <body onLoad="window.setInterval('window.scrollBy(0, 3)', 150)"> END_HTML for my $cnt ( 1 .. 1000 ) { print 'This is line #', $cnt, '<br />'; sleep(0.2); }
Re: Move to the end of an unbuffered CGI web page?
by TedPride (Priest) on Jan 04, 2005 at 19:58 UTC
    I wish this worked properly for updating status bar images. It does in Netscape (at least the older versions I tested it on), but IE does odd things with half of the image swaps and only finishes swapping them when the page completes. Danged buggy browser :(

    You can see if it works on your browser version here:
    http://www.home-school.com/cgi-local/update.pl

    It's supposed to update the bar by 1% every 3 seconds.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://419287]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found