I'm trying to develop a way to include static files in htm pages with
javascript.
I'm trying to use XMLHTTP object this way:
----------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>XMLHTTP</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
function include(xUrl,xId){
xmlhttp.open("GET", xUrl,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.getElementById(xId).innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null)
}
</script>
</head>
<body>
<script type="text/javascript">
include("header.htm", "xheader");
</script>
<div id="xheader"></div>
<hr>Corpo<hr>
<div id="xfooter"></div>
<script type="text/javascript">
include("footer.htm", "xfooter");
</script>
</body>
</html>
----------------------------------------------------------------------
header.htm and footer.htm are html examples files.
It doesn't work if I call header and footer but if I call only header it
works.
Any help much appreciated.
Best Regards.
--
Fabri
(Non è tuttu oru chiddu chi stralluci, né tuttu veru chiddu ca si dici)