Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 03-06-2008, 06:42 AM autoscroll?
Sharon_leic's Avatar
Super Talker

Posts: 115
Name: Sharon
Location: Leicester, uk
Trades: 0
Hiya!

is there any way i can make a javascript function to shoot a page to the bottom?

I made a simple chat script and need it to autoscroll to the bottom so the newest text is seen.

many thanks in advance for any help

Shaz x
__________________
mysql_connect("localhost", "brain", "sharon") or die(mysql_error());
mysql error: brain doesn't exist!
Sharon_leic is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-06-2008, 01:11 PM Re: autoscroll?
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
Just use
Code:
window.scroll(0,numPixels)
where numPixels is how far to scroll the page.
For example, paste the following string in the address bar to scroll this page.
Code:
javascript:window.scroll(0,5000);
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 03-06-2008, 05:50 PM Re: autoscroll?
Sharon_leic's Avatar
Super Talker

Posts: 115
Name: Sharon
Location: Leicester, uk
Trades: 0
ohh grate stuff, thanks!
i will have a play with that tomorrow.. must get ready now to hit the town! hehe

thanks again

Shaz x
__________________
mysql_connect("localhost", "brain", "sharon") or die(mysql_error());
mysql error: brain doesn't exist!
Sharon_leic is offline
Reply With Quote
View Public Profile
 
Old 03-06-2008, 07:21 PM Re: autoscroll?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Why not just put the newest text at the top and make it more user-friendly for everyone?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 03-07-2008, 01:32 PM Re: autoscroll?
Sharon_leic's Avatar
Super Talker

Posts: 115
Name: Sharon
Location: Leicester, uk
Trades: 0
because i want the newest text to go to the bottom like most chat/im programs :-)

willcode4beer
i have tried this as a function and just a straight script at the bottom of my text but not working.
it might be because the text gets sent to a DIV

any other idea's?

thanks

Shaz x
__________________
mysql_connect("localhost", "brain", "sharon") or die(mysql_error());
mysql error: brain doesn't exist!
Sharon_leic is offline
Reply With Quote
View Public Profile
 
Old 03-07-2008, 05:35 PM Re: autoscroll?
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
hmmm, might try scrolling the div instead of the window.

got a test page I can see?
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 03-07-2008, 06:05 PM Re: autoscroll?
Sharon_leic's Avatar
Super Talker

Posts: 115
Name: Sharon
Location: Leicester, uk
Trades: 0
I can only show you the code, i am writing my site and hosting it on my own pc with WAMP and cause i am 2nd on a network, wamp don't want to play with the outside world! lol

anyway, this is my code, sorry its messy, i am newish to it all lol

and there is more pages than this that handles the emotions, sending the messages to the database and so on but they not needed

main im page to hold it all together ( private.php )

PHP Code:
<?
include( "../inc/db.php" );
include( 
"../inc/cookieread.php" );
echo 
"<BODY TOPMARGIN=0 LEFTMARGIN=10>";
$query = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
$checker $query; include( "../inc/security.php" ); $query $checker;
echo 
"Private chat to ".$query."<br>";
echo 
"<iframe name='$query' id='$query' src='refresher.php?".$query."' height='250' width='305' frameborder='1' scrolling='yes'></iframe>";
echo 
"<form action='process_message.php' method='post' name='message'>
<input type='hidden' name='too' value='
$query' />
<input type='hidden' name='from' value='
$id' />
<input id='message' type=' text'size='39' maxlength='1000' name='message'>
</textarea>
<input type='submit' value='Send'>"
;
include( 
"smiles.html" );
?>
my file that calls the contents to add to the div (refresh.php )

PHP Code:
<?
$query 
= !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
$checker $quids; include( "../inc/security.php" ); $quids $checker;
echo 
"<script type='text/javascript' src='ajax.js'></script>
<script type='text/javascript'>
<!--
function refreshh(name) {

setTimeout('refreshh(name);',2000);
ajax.load('messages', 'content.php?'+name, true)
}
//-->
</script>"
;
echo 
"<BODY TOPMARGIN=0 LEFTMARGIN=0>";
echo 
"<div id='messages'></div>";
echo 
"<SCRIPT LANGUAGE='javascript'>refreshh(\"$query\");</SCRIPT>";
?>
my file that gets the text from the database (content.php )

PHP Code:
<?
include( "../inc/db.php" );
include( 
"../inc/cookieread.php" );
$quids = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
$checker $quids; include( "../inc/security.php" ); $quids $checker;
$datas explode("&"$quids);
$quids $datas[0];
$result mysql_query("SELECT * FROM im_messages WHERE fromm = '$username' AND too = '$quids' OR fromm = '$quids' AND too = '$username' ORDER BY ID");
while(
$row mysql_fetch_array$result )) {
echo 
$row[fromm] ." "$row[message] ."<br>";
}
?>
__________________
mysql_connect("localhost", "brain", "sharon") or die(mysql_error());
mysql error: brain doesn't exist!
Sharon_leic is offline
Reply With Quote
View Public Profile
 
Old 03-08-2008, 01:44 AM Re: autoscroll?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Sharon, I'm going to PM you a link. It's something I'm working on that's in the final stages, but it does demonstrate how to scroll to the bottom (via an arrow). You'll have to hack it a bit, but go nuts with it.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to autoscroll?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.74478 seconds with 12 queries