Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / Javascript

Javascript Injection at it's Finest!, without even using Eval()!

4.90/5 (6 votes)
15 May 2011CPOL 21.1K  
JS Injection
JavaScript
String.prototype.code = function(){ return (new Function('with(this) { return ' + this + '}' )).call({}); };
var s = 'alert("hello!");'
s.code();

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)