Hi, I am fairly new to Mozilla development and needed some help from the experts on the forum here.
I am not able to figure out how to render HTML content into the current browser window from the XPCOM component. I am writing a custom protocol handler (XPCOM component) which will fetch the HTML content using a given URL, manipulate it and then render the content to the browser. (For example, foo://www.google.com will render the content from http://www.google.com after doing some manipulation.) I am creating a new channel, doing an asyncOpen() on it and using a StreamListener to successfully get the data. (I will add the data manipulation part later). I am not sure how to render complete HTML document in the current browser window. Can someone please guide me on how to proceed ? Thanks, Maya Here is the code snippet - TestHttpListener.prototype = { mChannel : null, listenHttp: function() { // init the channel // the IO service var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); //Strip the protocol scheme and form an http:// URI. // create an nsIURI. Currently using a fixed http:// URI for test purposes... var uri = ioService.newURI("http://www.google.com", null, null); // get a channel for that nsIURI this.mChannel = ioService.newChannelFromURI(uri); // get a listener var listener = new StreamListener(); this.mChannel.asyncOpen(listener, null); }, QueryInterface: function(iid) { if (!iid.equals(Components.interfaces.nsISupports) && !iid.equals(kHTTPLISTENER_IID)) throw Components.results.NS_ERROR_NO_INTERFACE; return this; } }; function StreamListener() { } StreamListener.prototype = { mData: "", // nsIStreamListener onStartRequest: function (aRequest, aContext) { this.mData = ""; }, onDataAvailable: function (aRequest, aContext, aStream, aSourceOffset, aLength) { var scriptableInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); scriptableInputStream.init(aStream); this.mData += scriptableInputStream.read(aLength); }, onStopRequest: function (aRequest, aContext, aStatus) { if (Components.isSuccessCode(aStatus)) { dump(this.mData); dump("\n\nWant to Send the data to Browser......"); } else { // request failed dump("Request Failed."); } } //.......other related functions.... }; _______________________________________________ dev-tech-network mailing list dev-tech-network@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-network