Currently i am working on a plugin and widget based CMS.
A widget is a html/javasctript code snippet which always resides in a main div (say it widget div) element.
Using jquery and jquery-ui as javascript framework.
My Question:
How can we confine/sandbox html of the widget in the containing div so that if there is any improper html which can break layout of all the page can be avoided?
—- EDIT —-
OK i got an idea, is it feasible/possible on server side ?
- read the widget html from widget file
- check if it is proper html or not (using some html parser library).
- Fix it and past in template.
If you need to do it robustly, the only choice is to use an
iframe.If the widget HTML contained something like:
That’s going to break any page (that uses
divs, so in other words: all pages).From a now deleted comment: