OK, I had to rewrite your script a bit because it either is incomplete or relies on other loaded code that you did not supply, I changed it to this:
Code:
function de(txt){
return txt
}
var agmCiv;
var agmNom;
var agmNomJF;
var agmPnom;
var agmPic;
var agmEmail;
var agmLogin;
var agmOrg;
var agmMat;
var agmFic;
var agmSup;
function cacheDOM() {
alert('Start caching');
agmNom = de('txtNom');
agmNomJF = de('txtNomJF');
agmPnom = de('txtPre');
agmPic = de('txtPic');
agmEmail = de('txtEml');
agmLogin = de('txtLog');
agmOrg = de('txtOrg');
agmMat = de('txtMat');
alert('Done caching');
}
function node(x,n,d) {
if(x.item(n).childNodes.item(0)!=null) {
return x.item(n).childNodes.item(0).nodeValue;
} else {
return d;
}
}
function agmDisplayAgent() {
if(http.readyState == 4) {
if(http.responseText.substr(0,1) == "<") {
var oXML = http.responseXML;
var oRoot = oXML.documentElement.childNodes.item(0).childNodes;
alert(node(oRoot, 0));
agmNom.value = node(oRoot,1);
throbber(false);
}
}
}
function jsinit() {
// correctPNG();
alert('jsinit');
cacheDOM();
/* url = "/ag/ag.asp?p=2&uti=" + Uti();
http.open('GET', url, true);
http.onreadystatechange = agmDisplayAgent;
throbber(true);
http.send(null);*/
}
jsinit();
I also, tried out your 'solution' from the previous post some more and it produced errors in FF and wouldn't work at all there, even though it still worked in IE for the simple alert as mentioned before. This seemed to indicate a problem with it. So, I got rid of it and wrote this updated loadobjs() function (additions red):
Code:
function loadobjs(revattribute){
if (revattribute!=null && revattribute!=""){ //if "rev" attribute is defined (load external .js or .css files)
var objectlist=revattribute.split(/\s*,\s*/) //split the files and store as array
for (var i=0; i<objectlist.length; i++){
var file=objectlist[i]
var fileref=""
if (loadedobjects.indexOf(file)!==-1&&file.indexOf(".js")!=-1){
var scripts=document.getElementsByTagName('script')
for (var i_tem = 0; i_tem < scripts.length; i_tem++)
if (scripts[i_tem].src==file)
scripts[i_tem].parentNode.removeChild(scripts[i_tem])
var re=file+' '
loadedobjects=loadedobjects.replace(re, '')
}
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
}
Basically, this will remove any previously loaded script and reload it at the time it is requested, as if it had never been loaded. Except, of course, if it had altered any global variables the other time(s) it ran, those may still be in the state it left them in.
Using your method, I was having the same problem you were, with the above version, all three alerts fired each time. If you are still having problems, it is because your external script has errors. I'd use FF's javascript console to track them down, its output is much clearer (usually) than IE's error messages.
Bookmarks