For instance:
eval("alert('Hello there!');");
// is just as bad as?
window.location.href = "javascript:alert('Hello there!');void(0);";
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yeah, that’s the same : the string after
"javascript:"is evaluated to be executed.At least the first bad solution is more direct and obvious…
For a more general insight about why eval is evil, I’d redirect you to this other SO question.
But why would you use this kind of things ? It’s very very hard to find a legitimate case where it would simplify your code.