I'm using Google Caja to sanitize user input on my site. I'm currently processing the user's input inside the callback I pass to caja.whenReady(). However, on Microsoft Edge, the callback is never called because Edge can't be made safe by Caja. In the event that Caja doesn't work, I want to fall back to processing the user's content server side where I'll simply strip out all JavaScript.
How can I check if Caja works with the user's browser?
The code below will give you a function,
browserSupportsCaja()that will return true at any time after Caja calls itswhenReady()callbacks. This way you can determine if Caja is supported after it initializes.If you check for Caja support before it finishes initializing, then you will get a false negative. To catch that, just put the code that you want to execute after Caja is ready in a
whenReady()callback and assume that Caja is not available anywhere else.