HTML Sanitizer API
The setComments() method of the Sanitizer interface sets whether comments will be allowed or removed by the sanitizer.
Syntax
setComments(allow);
Parameters
allow- :
trueif comments are allowed, andfalseif they are to be removed.
- :
Return value
true if the operation changed the configuration, and false if the configuration already set comments to the specified value.
Examples
How to sanitize comments
The code below shows the basic usage of the setComments() method.
// Create sanitizer (in this case the default)
const sanitizer = new Sanitizer();
// Allow comments
sanitizer.setComments(true);
// Remove comments
sanitizer.setComments(false);
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
