0
$line=htmlentities(stripslashes($line));

This is the normal PHP statement. Can anyone tell me the Syntax in javascript to perform the above task through javascript??

3
  • 2
    Generally speaking, you shouldn't need to. Using createTextNode and friends, and avoiding innerHTML largely removes the need to worry about entities in JS. Commented Mar 6, 2013 at 17:18
  • You could possible use JQuery as answered here: stackoverflow.com/questions/1219860/… Commented Mar 6, 2013 at 17:28
  • The review above does not work Commented Mar 6, 2013 at 17:34

1 Answer 1

2

There is a library for this. It has an equivalent to PHP htmlentities function: http://phpjs.org/functions/htmlentities/

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @cclerville I found htmlspecialcharacters js on the same website suggected by you.. and it's worksing perfectly. phpjs.org/functions/htmlspecialchars

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.