Ver Mensaje Individual
  #4 (permalink)  
Antiguo 02/04/2008, 11:24
Avatar de vansert
vansert
 
Fecha de Ingreso: abril-2005
Mensajes: 28
Antigüedad: 19 años
Puntos: 0
Re: Cómo ejecutar Cód. JS y abrir los <scripts SRC> d una pag. obtenida con Ajax Resp

Hola GatorV

Ese post ya lo revise ayer y me funciono bastante bien.
Lo que no logro aun es poder ejecutar el código de los <scripts> embebidos. Y es fundamental que logre incluir scriptaculous y prototype ya que estoy haciendo una grilla editable (y funciona bien esta pagian sola) . Necesito resolver esto :(

Gracias y saludos!

Los embebidos:
Código:
<script type="text/javascript" src="librerias/scriptaculous/prototype.js"></script>
<script type="text/javascript" src="librerias/scriptaculous/scriptaculous.js"></script>
Siguiendo la linea del post q me recomendaste uso el script creado por MaBoRaK:

Código:
<script>
var tagScript = '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)';
        /**
        * Eval script fragment
        * @return String
        */
        String.prototype.evalScript = function()
        {
                return (this.match(new RegExp(tagScript, 'img')) || []).evalScript();
        };
        /**
        * strip script fragment
        * @return String
        */
        String.prototype.stripScript = function()
        {
                return this.replace(new RegExp(tagScript, 'img'), '');
        };
        /**
        * extract script fragment
        * @return String
        */
        String.prototype.extractScript = function()
        {
                var matchAll = new RegExp(tagScript, 'img');
                return (this.match(matchAll) || []);
        };
        /**
        * Eval scripts
        * @return String
        */
        Array.prototype.evalScript = function(extracted)
        {
                var s=this.map(function(sr){
                         var sc=(sr.match(new RegExp(tagScript, 'im')) || ['', ''])[1];
                         
						 if(window.execScript){
	                        	alert(sc);
                              	//window.document.execScript(sc);
                              	window.execScript(sc);
								//self.parent.document.execScript(sc);
					
						 }
                        else
                       {
						//setTimeout(((sr.match(new RegExp(sc, 'im')) || ['', ''])[1]),0);});	

                           window.setTimeout(sc,0);
                        }
                });
                return true;
        };
        /**
        * Map array elements
        * @param {Function} fun
        * @return Function
        */
        Array.prototype.map = function(fun)
        {
                if(typeof fun!=="function"){return false;}
                var i = 0, l = this.length;
                for(i=0;i<l;i++)
                {
                        fun(this[i]);
                }
                return true;
        };  
</script>