scrolling issue. pleeeezzzz help...

M

Mel

i have the following code and need to scroll the div to the bottom on each
of the inserts.

please help *&^%$#@

<a href=# onclick="addtext('Wed Mar 23 11:23:58 AM Eastern Standard Time
2005<BR>');">
<b>HELLO</b>
</a>
<div id=MyDiv style=height:200;overflow:auto class=normal style="border:1px
CCCCCC solid">
</div>
<script>

<!--- Hide script from browsers that don't understand JavaScript

function addtext(string) {
var c = new Date();
oDiv = document.getElementById("MyDiv");
oDiv.innerHTML = oDiv.innerHTML + string;
self.scroll(0, 50000);
}

addtext('1111595039<BR>');
addtext('1111595040<BR>');
addtext('1111595041<BR>');
addtext('1111595042<BR>');
addtext('1111595043<BR>');
addtext('1111595044<BR>');
addtext('1111595045<BR>');
addtext('1111595046<BR>');
addtext('1111595047<BR>');
addtext('1111595048<BR>');
addtext('1111595049<BR>');
addtext('1111595050<BR>');
addtext('1111595051<BR>');
addtext('1111595052<BR>');
addtext('1111595053<BR>');
addtext('1111595054<BR>');
// End hiding -->
</script>
 
K

kaeli

[email protected] enlightened said:
i have the following code and need to scroll the div to the bottom on each
of the inserts.

please help *&^%$#@

Tested in MSIE6 and Firefox 1.0

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
</head>

<body>
<a href=# onclick="addtext('Wed Mar 23 11:23:58 AM Eastern Standard Time 2005
<BR>');">
<b>HELLO</b>
</a>
<div id="MyDiv" style="width:400px;height:100px;overflow:scroll;border:1px
CCCCCC solid">
</div>
<script type="text/javascript">
function addtext(string)
{
var c = new Date();
oDiv = document.getElementById("MyDiv");
oDiv.innerHTML = oDiv.innerHTML + string;
oDiv.scrollTop = oDiv.scrollHeight;
}

addtext('1111595039<BR>');
addtext('1111595040<BR>');
addtext('1111595041<BR>');
addtext('1111595042<BR>');
addtext('1111595043<BR>');
addtext('1111595044<BR>');
addtext('1111595045<BR>');
addtext('1111595046<BR>');
addtext('1111595047<BR>');
addtext('1111595048<BR>');
addtext('1111595049<BR>');
addtext('1111595050<BR>');
addtext('1111595051<BR>');
addtext('1111595052<BR>');
addtext('1111595053<BR>');
addtext('1111595054<BR>');
// End hiding -->
</script>

</body>
</html>

--
 
E

ExGuardianReader

kaeli said:
Tested in MSIE6 and Firefox 1.0

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
</head>

<body>
<a href=# onclick="addtext('Wed Mar 23 11:23:58 AM Eastern Standard Time 2005
<BR>');">
<b>HELLO</b>
</a>
<div id="MyDiv" style="width:400px;height:100px;overflow:scroll;border:1px
CCCCCC solid">
</div>
<script type="text/javascript">
function addtext(string)
{
var c = new Date();
oDiv = document.getElementById("MyDiv");
oDiv.innerHTML = oDiv.innerHTML + string;
oDiv.scrollTop = oDiv.scrollHeight;
}

Now the challenge is to only scroll to the bottom if the div is already
at the bottom when the new text is added.

Ie, if the user has used the mouse to look back at the history, the div
just grows without changing the scrolling position.

A nice feature which I've tried in the past and never got exactly right!
 
K

kaeli

[email protected] enlightened said:
Now the challenge is to only scroll to the bottom if the div is already
at the bottom when the new text is added.

Ie, if the user has used the mouse to look back at the history, the div
just grows without changing the scrolling position.

A nice feature which I've tried in the past and never got exactly right!

I think for that you'd have to use clipping, similar to the scroller in the
link below, since you'd need to know the current position of things, when
things were changed by the user, and where the bottom is (that's the most
important part and I couldn't find a way to get whether something was at the
bottom without using this method).
More complicated, but quite possible.

http://www.quirksmode.org/js/layerscroll.html


--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top