November 27, 200718 yr Help. My javascript knowlegde is still limited. Here is my script. <script language='javascript'> var mydiv = document.getElementById("id"); mydiv.innerHTML = mydiv.innerHTML.replace("/abe/", "Hello World!"); </script> <div id="mydiv"> <p> Bogen, som handler om etik, blev skrevet i <b>år abe 45</b> f.kr. men var meget populær i renæssancen. </p> </div> What i am trying to do, is to define som innerHTML, "abe", and replace it with "Hello World!". But it does not work. Help? /jimmy
November 27, 200718 yr Author Nevermind, i found a way..... sharing: var innerhtmllol = document.getElementById('mydiv').innerHTML; var innerhtmlreplace = "<img src=\"http://www.w3schools.com/images/w3default80.jpg\" width=\"20px\" height=\"20px\">" innerhtmllol = innerhtmllol.replace(/ \:\) /g, innerhtmlreplace); document.getElementById('mydiv').innerHTML = innerhtmllol; var innerhtmllol = document.getElementById('mydiv').innerHTML; var innerhtmlreplace = "<img src=\"http://www.killersites.com/mvnforum/mvnforum/getavatar?memberid=1908\" width=\"20px\" height=\"20px\">" innerhtmllol = innerhtmllol.replace(/ \;\) /g, innerhtmlreplace); document.getElementById('mydiv').innerHTML = innerhtmllol;
November 27, 200718 yr it could be because your REGEX was wrong. you were using: "/abe/" whereas you may find success with just: /abe/ (no quotes)
December 27, 200718 yr php, I tried that and it didnt work either?? I no he already got it but im just wondering why it didnt work the first way??
December 27, 200718 yr php, I tried that and it didnt work either?? I no he already got it but im just wondering why it didnt work the first way?? Due to what Penguin said. His regex was wrong.
Create an account or sign in to comment