- il permet de copier un contenu XML (présent sous une balise <pre>) dans un textarea
- (surtout) il est compatible IE6 !
// Teste sur Firefox et IE6 //
// FIX de getElementById(...) pour MSIE
// src
if (/msie/i.test (navigator.userAgent)) {
document.nativeGetElementById = document.getElementById;
document.getElementById = function(id) {
// Get element using native method
var elem = document.nativeGetElementById(id);
if (elem) {
// If id match, return element
if (elem.attributes['id'].value == id) {
return elem;
}
// Otherwise look for the right one
else {
for (var i = 1; i < document.all[id].length; i++)
{
if (document.all[id][i].attributes['id'].value == id)
{
return document.all[id][i];
}
}
}
}
return null;
}
}
// Mise a jour d'un textarea avec le contenu d'un <pre>
var scPRE = document.getElementById('idBalisePreComportantDuXML');
var editTA = document.getElementById('idTextArea');
if (/msie/i.test (navigator.userAgent)) {
// FIX IE6 Textarea CR bug
editTA.value = "";
editTA.setAttribute("value" , scPRE.innerText ) ;
} else {
editTA.innerHTML = scPRE.innerHTML;
}
Aucun commentaire:
Enregistrer un commentaire