•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 423,340 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,164 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 827 | Replies: 4
![]() |
•
•
Join Date: Jun 2006
Posts: 18
Reputation:
Rep Power: 3
Solved Threads: 0
Hi,
I have a page which has a Div on it which gets constantly updated (every 1-3 seconds) but I want it to maintain its position between refreshes. I'm very very very new to Javascript and I am finding it very difficult to convert code that I've found online.
Can someone please point me in the right direction? So far the only code I've been able to find requires the code to make the div itself rather than modify an existing div.
Thanks.
Andrew.
I have a page which has a Div on it which gets constantly updated (every 1-3 seconds) but I want it to maintain its position between refreshes. I'm very very very new to Javascript and I am finding it very difficult to convert code that I've found online.
Can someone please point me in the right direction? So far the only code I've been able to find requires the code to make the div itself rather than modify an existing div.
Thanks.
Andrew.
•
•
Join Date: Aug 2006
Location: Noida, India
Posts: 158
Reputation:
Rep Power: 3
Solved Threads: 17
give some id to the div. And by using its id change the content of the div.
HTML:
javascript:
If this is not what u were expecting then explain ur problem in more details.
HTML:
html Syntax (Toggle Plain Text)
<div id="mydiv"></div>
javascript:
javascript Syntax (Toggle Plain Text)
var mydiv = document.getElementById("mydiv"); mydiv.innerHTML = "Any content that is to be updated.";
If this is not what u were expecting then explain ur problem in more details.
When you think you have done a lot, then be ready for YOUR downfall.
•
•
Join Date: Jun 2006
Posts: 18
Reputation:
Rep Power: 3
Solved Threads: 0
Sorry, I really didn't explain myself very well.
I'm making a chat style system with the newest messages at the bottom. At the moment every time the content is refreshed the div automatically scrolls to the bottom (which is what I want) but, if the user is scrolling up and reading a previous message then it also jumps to the bottom. Obviously it would be better if, when people are scrolling and the page refreshes, it maintains the position of the scroll on the div.
Is that any clearer? I'm not sure..
I'm making a chat style system with the newest messages at the bottom. At the moment every time the content is refreshed the div automatically scrolls to the bottom (which is what I want) but, if the user is scrolling up and reading a previous message then it also jumps to the bottom. Obviously it would be better if, when people are scrolling and the page refreshes, it maintains the position of the scroll on the div.
Is that any clearer? I'm not sure..
•
•
Join Date: Aug 2006
Location: Noida, India
Posts: 158
Reputation:
Rep Power: 3
Solved Threads: 17
Na, you can just measure. If you use ajax instead of refreshing the whole page, you will have a chance right after the ajaz call is made successfully to check the position of the scroll bar. If it's all the way at the bottom, then add the text, and push the scroll even farther. If it's not at the bottom, then the user is scrolling, so update the text but don't move the scroll bar.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: TypeError in an otherwise working script.
- Next Thread: PercentLoaded


Linear Mode