Alterando src dentro de textarea com ER

Add comments

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2.         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br" lang="pt-br">
  4. <head>
  5. <script type="text/javascript">
  6. function id( el ){
  7.         return document.getElementById( el );
  8. }
  9. window.onload = function(){
  10.         var imgs = document.getElementsByTagName(‘img’);
  11.         for( var i=0; i<imgs.length; i++ ){
  12.                 imgs[i].onclick = function(){
  13.                         var area = id(‘area’).value;                    
  14.                         id(‘area’).value = area.replace(/src="[-a-zA-Z0-9:_\/.]+"/, ’src="’+this.src+‘"’ );
  15.                 }
  16.         }
  17. }
  18. </script>
  19. </head>
  20. <body>
  21.         <form action="" method="post">
  22.                 <fieldset>
  23.                 <label><textarea cols="30" rows="7" id="area"><a href="http://www.site.com.br/index.php?user=2"><img src="../imagens/imagem.png" alt="" /></a></textarea></label>
  24.                 </fieldset>
  25.         </form>
  26.        
  27.         <img src="http://100grana.files.wordpress.com/2008/11/mickey-mouse-c.jpg" alt="" />
  28.         <img src="http://pcmeira.blog.uol.com.br/images/PatoDonald_pcmeira.jpg" alt="" />
  29. </body>
  30. </html>
julho 28th 2010 Não Classificados

Leave a Reply