carica l'oggetto piu' avanzato e facilmente aggiornabile la lista degli oggetti, al posto di mettere sempre il risultato dentro un div si possono trattare i dati come si vogliono all'interno di una funzione... dell'oggetto si puo' utilizzare sia il contenuto che sapere la sua dimensione
codice:<!--- // ****************************** // /* Author : Fabrizio Calderan * Date : 2005.11.14 * Url : http://www.fabriziocalderan.it Modificated : Sottana Marco Date : 2005.11.15 Url : http://www.brain-farm.com Icq : 210139517 */ -----> <html> <head> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> function funf(e){ f=document.getElementById("div_id"); f.innerHTML=""+ e.text + " "; f.innerHTML+="size = "+ e.size + ""; } </SCRIPT> <script type="text/javascript"> function createXMLHttp() { var xmlhttp ; try { xmlhttp = new XMLHttpRequest(); // Gecko (Firefox, Moz), KHTML (Konqueror, Safari), Opera, Internet Explorer 7 } catch (e) { var MSXML_XMLHTTP_PROGIDS = new Array( 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', // Internet Explorer 6 'Microsoft.XMLHTTP' // Internet Explorer 4,5 ); var success = false; for (var i=0;i < MSXML_XMLHTTP_PROGIDS.length && !success; i++) { try { xmlhttp = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]); success = true; } catch (e) {} } if ( !success ) { alert('Cant create XMLHttpRequest - not supported'); } } return xmlhttp; } function getFile(file,callbackFunction) { var xmlHttpObj = null; xmlHttpObj=createXMLHttp(); // xmlHttpObj.open("HEAD", file, true); xmlHttpObj.open('get', file); xmlHttpObj.onreadystatechange = function() { if (xmlHttpObj.readyState == 4) { switch(xmlHttpObj.status) { case 200: // Page found case 304: // Status Code on Opera when page reload this.size = xmlHttpObj.getResponseHeader("Content-Length"); this.text = xmlHttpObj.responseText; callbackFunction(this); return; break; case 0: // Worong protocol alert("001 Can't load file using 'file://' protocol") return; break; case 404: // Page not found alert("002 File not found: "+file); return; break; default: alert("003 Unrecognized status code: ["+xmlHttpObj.status+"]") return; break; } } } xmlHttpObj.send(null); delete xmlHttpObj; } </script> </head> <body> <div id="div_id"> </div> carica </script> </body>




Rispondi quotando