So I have www.siteA.com and www.siteB.com. Site A is my main site and site B is where I store some few web pages mostly html pages. I want to load a webpage from site B into a page of site A. So far, I have search SO about how to do this and found this one Insert external page html into a page html but it wont work on me. Here is the code I used from the link above:
<!DOCTYPE html>
<html>
<head>
<script>
function createRequestObject()
{
var obj;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
obj = new ActiveXObject("Microsoft.XMLHTTP");
}else{
obj = new XMLHttpRequest();
}
return obj;
}
function sendReq(req)
{
http.open('get', req);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse()
{
if (http.readyState == 4)
{
var response = http.responseText;
document.getElementById('here').innerHTML=response;
}
}
sendReq('http://www.siteB.com/file.html');
</script>
</head>
<body >
<div id="here"></div>
</body>
</html>
www.siteB.com/file.html file only contains this:
<!DOCTYPE html>
<html>
<head>
</head>
<body >
<h1>hello world!</h1>
<p><img src="http://www.siteB.com/img.jpg"/></p>
</body>
</html>
Any idea why it wont work on me? Or is it possible to load an external page from another domain?