I am creating an add-in for an application. Customers pay to browse some web pages and download some files from it. They want to automate this download process by adding. Therefore, instead of choosing “Save Page As” and waiting for the download to complete, they can click the add-in and forget the process. The problem is that the webpage provides some browser cookies. Thus, the best way is File-> "Save Page As." I want to do this through the addition. Is there a firefox-javascript way for this ?. I used nsiDownloader. But it only saves html, not pictures, etc. Can someone help me on this?
EDIT: Hi, This is the code that did the trick, thanks to sai prasad
var dir =Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); dir.initWithPath("C:\\filename"); var file = Components.classes["@mozilla.org/file/local;1"] .createInstance(Components.interfaces.nsILocalFile); file.initWithPath("C:\\filename.html"); var wbp = Components.classes['@mozilla.org/embedding/browser/nsWebBrowserPersist;1'] .createInstance(Components.interfaces.nsIWebBrowserPersist); alert("going to save"); wbp.saveDocument(content.document, file,dir, null, null, null); alert("saved");
EDIT: But, nevertheless, some web pages are not saved in the same way as "Save Page As". These saved pages are not displayed as source pages, they look like an example of html.
source share