Javascript code to overcome XSS vulnerability

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.

Skills: Javascript

See more: no code, using html code database, javascript sample code, need javascript, javascript websites, javascript solution, javascript write text, using javascript, website vulnerability, database sample code, quality website visitor, code sample, xss attacks code, smarty code javascript, write html javascript, vote code javascript, xss attack code, update code javascript, website using javascript, xss injection code, xss code

About the Employer:
( 22 reviews ) Moscow, Russian Federation

Project ID: #5042383

9 freelancers are bidding on average $27 for this job


I can fix this issue for you, but fixing this issue in JavaScript doesn't really make sense. This needs to be solved in server side script (let's say PHP, or ASP, etc.) before saved to database.

$30 USD in 1 day
(27 Reviews)

Hi, I am Umadevi, having 5+ years of experience in HTML,JavaScript,JQuery,Java,J2EE working in MNC, for developing web based product. I will do this job. Please contact me with the details

$20 USD in 3 days
(4 Reviews)

Hello! I can help you with this! .

$20 USD in 1 day
(7 Reviews)

Hello i was solving simmilar thing. I think i can handle this in one or two hours. Im newbie here on freelancer but in real life i work for prestige German company...

$35 USD in 3 days
(3 Reviews)

Hi, I'm a Spanish Web Engineer. Before writing the js code I have a question: Why don't you escape the data BEFORE saving it to the database? In PHP you can use the "htmlspecialchars" function, and in ASP .NET I remebe More

$10 USD in 4 days
(2 Reviews)

I have great experience in the area Core PHP, why not hire me for your PHP project. I have worked as an Graphic Designing Programmer and Graphic Designing Developer and have great experience in these areas. I More

$45 USD in 1 day
(1 Review)

Hi, I already have experience with exactly the same projects. What you can do is escaping text on backend side (with PHP for example, using htmlspecialchars function). If you want to escape it on frontend (wit More

$25 USD in 3 days
(1 Review)

Hi, I am interested in your project. Looking forward to work with you. Read the description and would like to start. Regards

$35 USD in 3 days
(0 Reviews)

Hi sir! My name is jester,an expert of WEB programming. I am very interested in your job , and i am ready for you now. Kindest regards!

$25 USD in 1 day
(0 Reviews)