IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

insertBefore suivi de appendchild


Sujet :

JavaScript

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Août 2009
    Messages
    42
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Août 2009
    Messages : 42
    Points : 23
    Points
    23
    Par défaut insertBefore suivi de appendchild
    est ce que quelqu'un peut m'aider svp quand je fait aller ce code j'ai un msg d'erreur :
    Erreur*: uncaught exception: [Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "http://www.biebuyck.com/newsite/index.php?lang=eng&sujet=home Line: 1596"]
    le probleme vien des 2 ligne ou j'ai marqué /*ici*/

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    var objects = document.getElementById("FTB_designEditor").contentDocument.body.getElementsByTagName("object");
    				for(var i=0;i<objects.length;i++){
    					var object = objects[i];
    					var idObj = object.id;
    					if (object.parentNode.getElementsByTagName("img")[0]){}
    					else if(document.getElementById("FTB_designEditor").contentDocument.getElementById("img"+idObj)) //deplacée
    					{
    						alert(object);
    			/*ici*/		var insertElement = document.getElementById("FTB_designEditor").contentDocument.insertBefore(object, document.getElementById("FTB_designEditor").contentDocument.getElementById("img"+idObj))
    			/*ici*/		insertElement.appendChild( document.getElementById("FTB_designEditor").contentDocument.getElementById("img"+idObj))
    					}
    					else //removed
    					{	
    				document.getElementById("FTB_designEditor").contentDocument.removeChild(object);
    				}
    					if (object.parentNode.getElementsByTagName("img")[0]){
    					var img = object.parentNode.getElementsByTagName("img")[0];
    					object.height = img.height;
    					object.width = img.width;}
    			  }
    			  var str;
    			  var inputs = document.getElementById("_variables").getElementsByTagName("input");
     
    			  if (document.getElementById("FTB_designEditor").contentDocument.body.innerHTML.replace (/\s+/g, \'\') !=""){ 
    document.getElementById("Texplication").value =  document.getElementById("FTB_designEditor").contentDocument.body.innerHTML;}
     
    		}

  2. #2
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    script type='text/javascript'>
    function surroundPic(){
    var mydiv=document.getElementById('cadre');
    mydiv.style.backgroundColor="red";
    mydiv.style.padding="10px";
    mydiv.style.display="inline";
    mydiv.id='cadre';
    document.body.insertBefore(mydiv,document.getElementById('mypic'))
    document.getElementById('cadre').appendChild(document.getElementById('mypic'))
    }
    </script>
    </head>
     
    <body onload="surroundPic()">
     
    <img id="mypic" src="HTMLstuff/1.jpg" width="124" height="108" />
     
    <div id="cadre"></div>
     
    </body>
     
    </html>

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Août 2009
    Messages
    42
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Août 2009
    Messages : 42
    Points : 23
    Points
    23
    Par défaut
    j'aurais besoin que ce code fonctionne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    <script type='text/javascript'>
    function surroundPic(){
    var mydiv=document.getElementById('aa').contentDocument.getElementById('cadre');
    mydiv.style.backgroundColor="red";
    mydiv.style.padding="10px";
    mydiv.style.display="inline";
    mydiv.id='cadre';
    document.getElementById('aa').contentDocument.body.insertBefore(mydiv,document.getElementById('mypic'))
    document.getElementById('aa').contentDocument.getElementById('cadre').appendChild(document.getElementById('mypic'))
    }
     
    function bb(){
    	document.getElementById('aa').contentDocument.body.innerHTML = ' <img id="mypic" src="HTMLstuff/1.jpg" width="124" height="108" /> <div id="cadre"></div>';
     
    }
    </script>
    </head>
     
    <body onLoad="bb();surroundPic()">
     
     <iframe id="aa" width="500" height="250"></iframe>
    </body>
     
    </html>
    ou si il existe un objet xml qui pourrais parser une page web entière et que je pourrais utiliser pour effectuer les opération que je dois effectuer ce serai cool

    ps: tjs en javascript c important!

Discussions similaires

  1. Probleme sur un AppendChild
    Par Toxine77 dans le forum XMLRAD
    Réponses: 3
    Dernier message: 14/03/2003, 18h25

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo