Qui : http://forum.html.it/forum/showthrea...hreadid=883374
Ripropongo il codice postato allora.
Nella stessa cartella dei 2 files seguenti, creare un file chiamato file2.txt. Riempirlo e salvare le modifiche. L'aggiornamento viene fatto ogni 4 secondi.
file : test2192.html
codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
//--------- Funzione per IE
function updateSpanTextIE() {
document.getElementById('textToView').src = 'test2192.php?ie';
} // function updateSpanTextIE()
//--------- Funzione per FF
var xmlDoc;
function updateSpanTextFF() {
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = loadFile;
xmlDoc.load("test2192.php");
} // function updateSpanTextFF()
function loadFile() {
var x = xmlDoc.getElementsByTagName('main');
myText = '';
for (i=0;i<x.length;i++) {
for (j=0;j<x[i].childNodes.length;j++) {
if (x[i].childNodes[j].nodeType != 1) continue;
myText += x[i].childNodes[j].firstChild.nodeValue;
} // for (j=0;j<x[i].childNodes.length;j++)
} // for (i=0;i<x.length;i++)
//------------ Rimpiazza gli a capo con
myText = myText.replace(/\n/ig,'
');
myText = myText.replace(/\[/ig,'<');
myText = myText.replace(/\]/ig,'>');
document.getElementById('spanText').innerHTML = myText;
} // function loadFile()
//--------- Funzione per FF
function updateSpanText() {
if (document.implementation && document.implementation.createDocument) {
setInterval("updateSpanTextFF()",4000);
} else {
if (window.ActiveXObject) {
setInterval("updateSpanTextIE()",4000);
} else {
alert('browser non gestito');
} // if (window.ActiveXObject)
} // if (document.implementation && document.implementation.createDocument)
} // function updateSpanText()
//-->
</script>
</head>
<body onload="updateSpanText()">
<XML id="textToView" src="test2192.php?ie"></XML>
<hr>
<span id="spanText" DATASRC="#textToView" DATAFLD="TEXT"></span>
<hr>
</body>
</html>
file : test2192.php
codice:
<?php
if (isset($_GET['ie'])) {
echo "<?xml version=\"1.0\"?>";
} else {
header("Content-Type: text/xml");
} // if (isset($_GET['ie']))
?>
<main>
<text>
<?php
include("file2.txt");
?>
</text>
</main>