Hey
Im having difficulty with editing a div inner html.
Im trying to split it on the
then only show the latest 4 lines but it won't work.
This is what i got:
PHP Code:
var original = function Chat(div, url) {
this.div = div;
this.url = url;
this.start = new Date().getTime();
this.start = function(lastupdate) {
lastupdate = lastupdate ? lastupdate : new Date().getTime()
ajaxPost(this.url, 'lastupdate='+ lastupdate, function(up) {
return function() {
if (this.readyState == 4) {
// success
if(this.status == 200) {
var data = eval('(' + this.responseText + ')');
// start next timer
up.start(data.lastupdate);
// fill chat
//STRING MANIPULATION HERE
var original = document.getElementById(up.div).innerHTML;
var index = original.indexOf('<br>') + 4;
var partial = original.substr(index);
document.getElementById(up.div).innerHTML = partial + data.html;
}
// connection error
else {
// try again in .8 of a seconds
setTimeout(function(){
up.start(lastupdate);
}, 800);
}
}
};
}(this));
};
}
var chat = new Chat('chat', 'getnewmessages.php');
The script works fine except trying to edit the string to only show a max amount of lines. How can i get this work ?
Please help!
Thanks
Bookmarks