I am having a site in which dynamically header part is changing as in each and every page there is a script called which checks the referring url and according to that url script invoke a header.html which is used in AJAX and called as .txt file using XMLHttp.open .
Complete HTML page is imported but if there is any javascript code exists in the header.txt. Javascript code does not get executed.
Can any body help me out how to use javascript codeusing AJAX function used as follows.
Complete HTML page is imported but if there is any javascript code exists in the header.txt. Javascript code does not get executed.
Can any body help me out how to use javascript codeusing AJAX function used as follows.
Code:
function loadXMLDoc(url)
{
//alert("URL "+url);
head_url = url + "header.txt";
button_url = url + "buttons01.txt";
foot_url = url + "footer.txt";
fill_url = url + "fill.gif";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",head_url,false);
xmlhttp.send(null);
document.getElementById('header').innerHTML = xmlhttp.responseText;
//alert("head url "+head_url);
xmlhttp.open("GET",foot_url,false);
xmlhttp.send(null);
document.getElementById('footer').innerHTML = xmlhttp.responseText;
document.getElementById('but').style.backgroundImage = "url(" + fill_url + ")";
}
Comment