0

I have a textarea where I let users write some HTML.

They can then click a "Preview" link that triggers ajax that sends the raw HTML to a controller that uses JSoup to sanitize it (it returns the sanitized string).

I then display the sanitized HTML in a modal dialog box.

This all works wonderfully except that the modal dialog box has CSS styles cascade down from the rest of my site, and I want to display the HTML preview without any styles.

I've searched a lot (e.g. I found Any way to display some heavily-styled HTML in isolation from the rest of site's styles?) but wasn't able to figure out a solution.

I appreciate your help!

-Ryan

Community
  • 1
  • 1
Ryan
  • 22,332
  • 31
  • 176
  • 357

1 Answers1

0

You could write the preview to a text file on the server then open an iframe to it with a template absent of the site's css.

I bet your problem stems from generic css selectors though. Things like

div p{
    background:#fff;
}

Or maybe not so generic, but so non specific that it is being caught by your preview.

Kai Qing
  • 18,793
  • 5
  • 39
  • 57