This may remove some of the flexibility, and it doesn’t answer all of the questions, but personally I think this would be a saner way to introduce HTML overlays.
The problem is that we still have to parse out our HTML. The useful thing about using XML is that XMLHttpRequest will parse it and return you a nice DOM tree. We could send our HTML overlay as XML to XMLHttpRequests and as HTML for regular requests, but this makes things messy and adds some unwanted complexity. Mozilla and the latest version of Opera provide us with a DOMParser object we can use to turn our HTML string into a DOM tree, but that doesn’t help IE users.
The best solution I can think of is to add a new
<overlay> element to
our HTML overlays to make them easy to extract with a regular
expression. Browsers displaying the HTML would ignore it and our
<overlay id="myOverlay"> <p>This is content in an overlay.</p> </overlay>
I’ve put up a demo of my version of HTML overlays in action.