js file for including menu.html. Call the js file: include_menu.js:
Code:
function include(url){
var pageRequest = false //variable to hold ajax object
/*@cc_on
@if (@_jscript_version >= 5)
try {pageRequest = new ActiveXObject("Msxml2.XMLHTTP")}
catch (e){try {pageRequest = new ActiveXObject("Microsoft.XMLHTTP")}
catch (e2){pageRequest = false}}
@end
@*/
if (!pageRequest && typeof XMLHttpRequest != 'undefined')
pageRequest = new XMLHttpRequest()
if (pageRequest){ //if pageRequest is not false
pageRequest.open('GET', url,false) //get page synchronously
pageRequest.send(null)
document.write(pageRequest.responseText);
}
}
include('menu.html')
In menu.html: anything you want. Put some text in it to test.
In each page in which you want to include menu.html, something like:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title></title>
</head>
<body>
<div>
This is text from your main page<br>
<script type="text/javascript" src="include_menu.js"></script>
</div>
</body>
</html>
===
Arie Molendijk.
Bookmarks