How can I turn a string of HTML into a DOM object in a Firefox extension?
Ajaxian actually had a post on inserting / retrieving html from an iframe today. You can probably use the js snippet they have posted there.
As for handling closing of a browser / tab, you can attach to the onbeforeunload (http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx) event and do whatever you need to do.
Try this:
var request = new XMLHttpRequest();
request.overrideMimeType( 'text/xml' );
request.onreadystatechange = process;
request.open ( 'GET', url );
request.send( null );
function process() {
if ( request.readyState == 4 && request.status == 200 ) {
var xml = request.responseXML;
}
}
Notice the overrideMimeType and responseXML.
The readyState == 4
is 'completed'.