Finally after a good amount of research in Google I have found how to include a HTML page in another HTML page. We can insert a HTML page in one of the DIV or SPAN Tags of other HTML page. Below is the Java Script function for including a HTML page in another HTML page.
Function:
function clientSideInclude(id, url) {
var req = false;
// For Safari, Firefox, and other non-MS browsers
if (window.XMLHttpRequest) {
try {
req = new XMLHttpRequest();
} catch (e) {
req = false;
}
} else if (window.ActiveXObject) {
// For Internet Explorer on Windows
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
req = false;
}
}
}
var element = document.getElementById(id);
if (!element) {
alert("Bad id " + id + "passed to clientSideInclude." +"You need a div or span element " + "with this id in your page.");
return;
}
if (req) {
// Synchronous request, wait till we have it all
req.open('GET', url, false);
req.send(null);
element.innerHTML = req.responseText;
} else {
element.innerHTML = "Sorry, your browser does not support " + "XMLHTTPRequest objects. This page requires " + "Internet Explorer 5 or better for Windows, " + "or Firefox for any system, or Safari. Other " + "compatible browsers may also exist.";
}
}
Example:
There are two HTML Pages by name one.html and two.html.
one.html:
<html>
<head>
<title>one</title>
</head>
<body>
Hello this is one.html
</body>
</html>
two.html:
<html>
<head>
<title>two</title>
</head>
<body>
<div onclick=”clientSideInclude(‘two’,’one.html’);”>Hello this is two.html</div>
<div id=”two”></div>
</body>
</html>
Explanation:
Include the above mentioned function in the two.html. and run the file two.html using any browser. when the text “Hello this is two.html” the function is called and the div with id “two” will be loaded with the text from the one.html.