Sorry I missed that. Well, you can convert regular text contents fetched via Ajax, say:
Code:
[24-07-2010 20:17:11] * Song 1
[24-07-2010 20:21:11] * Song 2
[24-07-2010 20:25:18] * Song 3
[24-07-2010 20:29:58] * Song ...
into a JavaScript array, which each line stored as an array element. Lets say "page_request.responseText" is the returned Ajax object that contains the raw contents of your text file- to transform that into an array of contents, you'd do:
Code:
var messages=page_request.responseText.split("\n")
Now messages[0] contains "[24-07-2010 20:17:11] * Song" for example.
With that said, and using a modified version of Ajax Includes Script, the below displays the 1st line of your text file each time the page is loaded:
Code:
<script type="text/javascript">
/***********************************************
* Ajax Includes script- Đ Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var rootdomain="http://"+window.location.hostname
function ajaxinclude(url) {
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.open('GET', url+"?bustcache="+new Date().getTime(), false) //get page synchronously
page_request.send(null)
writecontent(page_request)
}
function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200){
var messages=page_request.responseText.split("\n")
document.write(messages[0])
}
}
</script>
<body>
<script type="text/javascript">
ajaxinclude("tickercontent.txt")
</script>
Be sure to change tickercontent.txt to the name of your text file.
Bookmarks