0
私はFirefox拡張機能を作成しようとしています。なぜ私はdocument.body.innerHTML = data;を使用したいのですか?新しい開いたタブで、それは動作しません。ここに私のコードです:Googleは内部化したくありません(XPCOM)
function change() { //Open google in new Tab and select it tab=gBrowser.addTab("http://www.google.com"); gBrowser.selectedTab=tab; //Create nslFile object var path="/home/foo/notify.txt" var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(path); //Put file content into data variable var data = ""; var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"]. createInstance(Components.interfaces.nsIFileInputStream); var cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]. createInstance(Components.interfaces.nsIConverterInputStream); fstream.init(file, -1, 0, 0); cstream.init(fstream, "UTF-8", 0, 0); // you can use another encoding here if you wish let (str = {}) { cstream.readString(-1, str); // read the whole file and put it in str.value data = str.value; } cstream.close(); // this closes fstream //change content of google page by file content document.body.innerHTML = data; }