Get started with js-xss CDN

MIT licensed

Js-XSS: Automatically escapes user input in JS apps to prevent XSS attacks.

Tags:
  • sanitization
  • xss
  • sanitize
  • sanitisation
  • input
  • security
  • escape
  • encode
  • filter
  • validator
  • html
  • injection
  • whitelist

Stable version

Copied!

How to start using js-xss CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with js-xss CDN - cdnhub.io</title>
    <script src="https://cdn.cdnhub.io/js-xss/1.0.15/xss.min.js"></script>
</head>
<body>
    <button id="inject-xss">Inject XSS</button>
    <script>
        document.getElementById('inject-xss').addEventListener('click', () => {
            const xssLibrary = new XSS();
            const userInput = document.createElement('div');
            userInput.innerHTML = xssLibrary.sanitize('<script>alert("XSS Attack!");</script>');
            document.body.appendChild(userInput);
        });
    </script>
</body>
</html>

All versions