Quantcast
Viewing all articles
Browse latest Browse all 2

Mootools extractScripts

here’s the useful implementation for extracting scripts from text or html code:

String.implement({
	extractScripts:function(){
    	var r, h=this.stripScripts(function(js){	r=js;	});	return r;
    }
});

And you would use it like this:

script="some text <script> alert('hi'); </script>".extractScripts();
$exec(script);  //says 'hi'

Viewing all articles
Browse latest Browse all 2

Trending Articles