Click here to Skip to main content
15,867,568 members
Articles / Programming Languages / Javascript
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
4.90/5 (6 votes)
15 May 2011CPOL 20.5K   8   1
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)


Written By
Software Developer (Senior) Codevendor
United States United States
Please visit my personal website https://codevendor.com for my latest codes and updates.

Comments and Discussions

 
GeneralVery interesting solution! Pin
DrABELL15-May-11 16:17
DrABELL15-May-11 16:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.