system9898
Programmer
I have a page which in the main document, the css includes a background image. Then, you click on a link and ajax dynamically loads another page. The problem is, that the new AJAX page seems to be using the master doc's css and not the new page's css, which it should. That makes total sense as to why, but how do I correct this? I need to load a new css, just for that ajax block...
Here's the ajax code:
Here's the ajax code:
Code:
function ahah(url, target) {
n = Math.floor(Math.random()*50);
img = 'ani_progressindicator.gif'; //default
if (n % 5 == 0) img = 'ani_snacky.gif';
if (n % 5 == 1) img = 'ani_snackyhead.gif';
document.getElementById(target).innerHTML = ' <img src="/images/' + img + '">';
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req != undefined) {
req.onreadystatechange = function() {ahahDone(url, target);};
req.open("GET", url, true);
req.send("");
}
}
function ahahDone(url, target) {
if (req.readyState == 4) { // only if req is "loaded"
if (req.status == 200) { // only if "OK"
obj=document.getElementById(target);
obj.innerHTML = req.responseText;
execJS(obj);
} else {
document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
}
}
}
function load( div, name) {
ahah(name,div);
//document.getElementById(div).style.backgroundColor="#F6F6F6";
return false;
}
function execJS(node) {
var bSaf = (navigator.userAgent.indexOf('Safari') != -1);
var bOpera = (navigator.userAgent.indexOf('Opera') != -1);
var bMoz = (navigator.appName == 'Netscape');
var st = node.getElementsByTagName('SCRIPT');
var strExec;
for(var i=0;i<st.length; i++) {
if (bSaf) {
strExec = st[i].innerHTML;
} else if (bOpera) {
strExec = st[i].text;
} else if (bMoz) {
strExec = st[i].textContent;
} else {
strExec = st[i].text;
}
try {
eval(strExec);
} catch(e) {
alert(e);
}
}
}