Scroll to Bottom problem in chat area...

Asked by R. Rigaud

No, there isn't any problem with Sameplace, Scroll is good...

It's for my app built on X4M... I copy your Scroll functions :

function isNearBottom(domElement, threshold) {
    return Math.abs(domElement.scrollHeight -
                    (domElement.scrollTop + domElement.clientHeight)) < (threshold || 24);
}
function scrollingOnlyIfAtBottom(domElement) {
    if(isNearBottom(domElement))
        scrollToBottom(domElement);
}
function scrollToBottom(domElement) {
        domElement.scrollTop = domElement.scrollHeight - domElement.clientHeight;
}

After insterting a new message to my XHTML Doc. in my iframe, I've tested :

var chat_area = $(jid + "_iframe").contentWindow.document.getElementById("chat-area");
scrollToBottom(chat_area);
// or : scrollingOnlyIfAtBottom(chat_area);

Where my XHTML Doc is :

<body>
 <div id="chat-area">
  <table width="100%" border="0" cellspacing="0" id="messages" />
 </div>
 <div id="bottom"></div>
</body>

But it doesn't work....

I also tryed another method with anchors, based on what I've seen on the Web :

$(jid + "_iframe").location = $(jid + "_iframe").location + "#bottom";

But no Result...

It's a huge problem because without a autoscroll, it's impossible to chat correctly...

Thank you so much if you could help me on this problem...

Question information

Language:
English Edit question
Status:
Solved
For:
SamePlace Edit question
Assignee:
No assignee Edit question
Solved by:
R. Rigaud
Solved:
Last query:
Last reply:
Revision history for this message
R. Rigaud (raph-rigaud) said :
#1

Well, I feel very stupid...

I work on it all day... I fail each time... I post a topic... and 10 minutes later, I find a solution.

Not the best, because it's using my second method (less good than yours... because a user just can't read previous messages by scrolling because if somebody send a message, it scroll his iframe without preventing)

The "solution" was :
$(jid + "_iframe").contentWindow.location = "chrome://ylifecore/content/modules/simplechat/templates/simple.xhtml#bottom";
Is was the "contentWindow" that was missing.

If you find the problem with your method, it would be better, thank you.

Revision history for this message
R. Rigaud (raph-rigaud) said :
#2

Well I closed this ticket... I don't like to see it open... XD