Javascript code to overcome XSS vulnerability

Javascript code to overcome XSS vulnerability

Cancelled

Job Description

I need javascript code which escapes the data before placing it into HTML page to prevent XSS vulnerability.

Situation: Website visitor enters text to a field on website. The website saves it into database. Later websites renders the text directly in HTML causing XSS vulnerability.
Solution: Escape the text using javascript before rendering it in HTML. However I have no code to do this. Please write quality code sample.

Other open jobs by this client