jueves, 27 de junio de 2013

Loading - JQuery

 1 <html>
 2  <head>
 3      <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.
 4                  1/jquery.min.js"></script>
 5      <script>
 6    $(function(){
 7     $('body')
 8      .append(
 9       $('<div id="model-protector" align="center"></div>')
10        .css({
11         position: 'fixed',
12         top: 0,
13         background: 'rgba(0,0,0,0.8)',
14         width: '100%',
15         height: '100%',
16        })
17        .html('<img src="http://argoscti.com/wp-
18              content/themes/Realist/Realist%20Wordpress%20The
19              me/images/loading.gif" style="height: 50px; 
20              width: 50px;margin-top:25%;" /><br/><button 
21              id="cerrar_modal" type="button">Ocultar</button>
22              ')
23      );
24     
25      $('#cerrar_modal')
26       .click(function(){
27        $('#model-protector')
28         .fadeOut(function(){
29          $(this).remove();
30         });
31        });
32     });
33    </script>
34     </head>
35     <body></body>
36 </html>

Javascript - Replace All

Un muy sencillo script para un replace all ... diviertansen!!

 1 function replaceAll( busca, reemplaza, text ){
 2        var regex = new RegExp(busca, 'g');
 3        text = text.replace(regex, reemplaza);
 4        return text;
 5 }