简体   繁体   中英

Sanitize innerHTML in javascript

I am using that block of code and bring told by a code validator that this should be sanitized.

What is wrong with it and how can i sanitize it?

el1 = document.getElementById('quote'); //this is fine
el1.innerHTML = quoteNew; //this should be sanitized

如果quoteNew的内容只是要显示的文本,则使用textContent属性。

 el1.textContent = quoteNew;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM