rss

Copier du XML dans un textarea (sous IE6)

Voici un petit bout de code JavaScript :
- 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

Mots clés du blog

10.1 4G acceptancetest adb androï Android androïd Android7 api appender appengine application applications archive array assistantematernelle astuce auth0 authentication authority automation Axis bash bearer blog boot bootloader bower build bundle c calendrier camille combal cdi certificate cf client cloudfoundry collaboratif command commandes connexion console css cyanogen decrypt démasquées démasquer développement dll dump easter eggs écologie écrit employeur EMUI EMUI5.0 encrypt enfant évènement export-package ExtJS fab fastboot fiche find firefox gadget galaxytab gelf gem git gmail gnupg gooelappengine google gparted gpg gpg2 gps graylog grenoble Grid gui harddrive heroku hover howto HTML http https IE ihm immobilier imprimante innovation insolite instance integration Java JavaScript jenkins jeu jobs json json-schema-validator key keystore labs linux livre log log4j logger logs lombok masquées masquer maven maven-gae-plugin Mémoire microsoft mobile mockito mondialisation monitor MUSE musique en ligne myopera nodejs npm NT NTEventLogger onglet openstack osgi paas package parameters parent php politique prosyst prototype proxies proxy quartz radio rappel recherche regex repository resize RIA ridge rock ROM route ruby rubygems s8500 samsung scheduler scm secret secure sel selenium Serializer server shared shell sign signature slf4j smartphone so société song spy ssh ssl struct swagger swig tâches téléphone téléréalité test thunderbird timeout token Tomcat tooltip tooltips truststore TWRP ubuntu unit test validator verify virgin virtualbox wave waze web WebApp wiki wikimedia wikipédia wikipen wiko windows windows10 yahoo youtube yum