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>XMLHTT P</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.XMLHT TP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest! ='undefined') {
xmlhttp = new XMLHttpRequest( );
}
function include(xUrl,xI d){
xmlhttp.open("G ET", xUrl,true);
xmlhttp.onready statechange=fun ction() {
if (xmlhttp.readyS tate==4) {
document.getEle mentById(xId).i nnerHTML = xmlhttp.respons eText;
}
}
xmlhttp.send(nu ll)
}
</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)
javascript.
I'm trying to use XMLHTTP object this way:
----------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>XMLHTT P</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.XMLHT TP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest! ='undefined') {
xmlhttp = new XMLHttpRequest( );
}
function include(xUrl,xI d){
xmlhttp.open("G ET", xUrl,true);
xmlhttp.onready statechange=fun ction() {
if (xmlhttp.readyS tate==4) {
document.getEle mentById(xId).i nnerHTML = xmlhttp.respons eText;
}
}
xmlhttp.send(nu ll)
}
</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)
Comment