textarea include text

Posted by: 邱小新 at 上午10:52:00 in
<script language="JavaScript" type="text/javascript"> function includeTEXT() { var z, i, elmnt, file, xhttp, file_array, attr; /* Loop through a collection of all HTML elements: */ z = document.getElementsByTagName("*"); for (i = 0; i < z.length; i++) { elmnt = z[i]; /*search for elements with a certain atrribute:*/ file = elmnt.getAttribute("w3-include-html"); if (file) { file_array = file.split(";"); /* Make an HTTP request using the attribute value as the file name: */ xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4) { if (this.status == 200) {elmnt.value += this.responseText;} if (this.status == 404) {elmnt.value = "Page not found.";} /* Remove the attribute, and call this function once more: */ if (file_array.length > 1) { attr = ""; for (i=1; i<file_array.length; i++) attr += file_array[i]; elmnt.setAttribute("w3-include-html", attr) } else { elmnt.removeAttribute("w3-include-html"); } includeTEXT(); } } xhttp.open("GET", file_array[0], true); xhttp.send(); /* Exit the function: */ return; } } } </script> <body onload="initPage()"> <textarea cols="80" rows="30" wrap="off" w3-include-html="messages.0;messages"></textarea> </body>