What I want to do is: a web page with constantly updated content. (In my case, it is updated every 2 seconds). New content is added to the old, not rewritten.
Here is the code I have:
var msg_list = new Array( "<message>Hello, Clare</message>", "<message>Hello,Lily</message>", "<message>Hello, Kevin</message>", "<message>Hello, Bill</message>" ); var number = 0; function send_msg() { document.write(number + " " + msg_list[number%4]+'<br/>'); number = number + 1; } var my_interval = setInterval('send_msg()', 2000);
However, only one line is printed in IE and Firefox, and the page will no longer be updated. Interestingly, in Chrome, lines are printed continuously, and this is what I am looking for.
I know that document.write () is called when the page loads according to this link . As such, this is definitely not a way to keep the web page up to date. What would be the best way to achieve what I want to do?
Completely new to Javascript. Thanks.
Lily
source share