1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| // SetInnerHTML Sécurisé
function setInnerHTML(divContent, HTML) {
divContent.innerHTML=HTML;
var All=divContent.getElementsByTagName("*");
for (var i=0; i<All.length; i++) {
All[i].id=All[i].getAttribute("id")
All[i].name=All[i].getAttribute("name")
All[i].className=All[i].getAttribute("class")
}
var AllScripts=divContent.getElementsByTagName("script")
for (var i=0; i<AllScripts.length; i++) {
var s=AllScripts[i];
if (s.src && s.src!="") {
// Précédement asynchrone, mis en synchrone pour éviter des problèmes de dépendances de scripts
eval(getFileContent(s.src))
}
else {
eval(s.innerHTML)
}
}
}
// Renvoie le texte de l'objet ActiveXObject le plus récent depuis une liste
var pickRecentProgID = function (idList){
// found progID flag
var bFound = false;
for(var i=0; i < idList.length && !bFound; i++){
try{
var oDoc = new ActiveXObject(idList[i]);
o2Store = idList[i];
bFound = true;
}catch (objException){
// trap; try next progID
};
};
if (!bFound)
throw ("Aucun ActiveXObject n'est valide sur votre ordinateur, pensez à mettre à jour votre navigateur");
idList = null;
return o2Store;
}
// Retourne un nouvel objet XmlHttpRequest
var GetXmlHttpRequest_AXO=null
var GetXmlHttpRequest=function () {
if (window.XMLHttpRequest) {
return new XMLHttpRequest()
}
else if (window.ActiveXObject) {
if (!GetXmlHttpRequest_AXO) {
GetXmlHttpRequest_AXO=pickRecentProgID(["Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]);
}
return new ActiveXObject(GetXmlHttpRequest_AXO)
}
return false;
}
function getFileContent(url) {
var Xhr=GetXmlHttpRequest();
Xhr.open("GET",url,false);
Xhr.send(null);
return Xhr.responseText;
} |
Partager