Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When working with AJAX.NET you can use the <code>PageRequestManager</code> in JavaScript to monitor an AJAX callback being finished; specifically, it's <code>endRequest</code> event.</p> <p>From what I can see, you haven't shown us your code for making sure the scrollbar is always at the bottom, but it seems from your comment that it constantly scrolls the div down, so I suggest you move the part of your code that scrolls the div down, from whatever <code>setInterval</code> you've been using, to the <code>endRequest</code>, and include a check in <code>endRequest</code> to see if the value has changed:</p> <pre><code>var contentLength = 0; var requestMan = Sys.WebForms.PageRequestManager.getInstance(); requestMan.add_endRequest(function() { // get a reference to your ChatContent div, by whatever means you prefer var container = document.getElementById( /* your ChatContent id */ ); // this is fired at the end of a javascript callback // check if new posts were added in this callback if(content.innerHTML.length &gt; contentLength) { // update this var, so that the same check won't evaluate to true at next callback contentLength = content.innerHTML.length; // scroll the div to its bottom, by whichever means you were doing it before content.scrollTop = 100000; } }); </code></pre> <p><strong>EDIT</strong></p> <p>Based on your input, I'll revise my answer, so that it uses your code, and requires as few changes as possible. What you've got there, is code that keeps scrolling down the DIV, and you want to change it so that it only scrolls the DIV if the content of the DIV has changed:</p> <pre><code> &lt;script type="text/javascript"&gt; var contentLength = 0; // add this global var Sys.Application.add_load(function() { var t = document.getElementById('ChatContent'); if(t.innerHTML.length &gt; contentLength) // &lt;- add a condition here t.scrollTop = t.scrollHeight; }); &lt;/script&gt; </code></pre> <p>Just replace your script block with this, in your updatepanel, and you should be able to leave the rest as it is.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload