Skip to content

$.xss()

Arthur Guiot edited this page Jul 4, 2017 · 1 revision

How it works?

This function is basically a function to prevent Cross-site scripting. So what this function does is that you give it a string and it returns you the same string but with encoded special characters.

How to use it?

It's super simple, you just need to give it a string, like that:

// Creating DisplayJS variable
var $ = new DisplayJS(window);
// String we want to encode
var str = "<b>After conversion, I won't be interpreted as HTML 😊</b>";
// Executing the function
var result = $.xss(str)
// printing the result
console.log(result)

$.xssURI()

Want to send GET data but you can have html in it? Instead of $.xss(), just use $.xssURI(). It works exactly the same as $.xss().


⚠️ Questions?

Don't hesitate to ask your questions ⁉️ in the issue part 😁

Clone this wiki locally