Forum Moderators: open
[edited by: whoisgregg at 9:37 pm (utc) on Apr 28, 2010]
[edit reason] Exemplified URL :) [/edit]
window.onload=function() { write_external_content('url-to-your.php'); };
//
function write_external_content(url) {
if (document.getElementById('write-me')) {
var element = document.getElementById('write-me');
element.innerHTML = '<em>Loading Content ...</em>';
xmlHttp=GetXmlHttpObject();
xmlHttp.open("GET", url);
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
element.innerHTML = xmlHttp.responseText;
}
else { element.innerHTML = 'Oops. Request failed.'; }
}
xmlHttp.send(null);
}
}
//
function GetXmlHttpObject() {
var xmlHttp=null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e) {
//Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}