Click here to Skip to main content
16,018,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my Extension code:

chrome.manifest file

CSS
content ActiveXSupporter content/
overlay chrome://browser/content/browser.xul chrome://ActiveXSupporter/content/activeXsupporter.xul


install.rdf

XML
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<!-- Required Items -->
<em:id>nupur.parashar09@gmail.com</em:id>
<em:name>ActiveXSupporter</em:name>
<em:version>1.0</em:version>

<em:targetApplication>
     <Description>
         <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
         <em:minVersion>1.5</em:minVersion>
         <em:maxVersion>11.0.*</em:maxVersion>
     </Description>
</em:targetApplication>

<!-- Optional Items -->
<em:creator>Nupur Parashar</em:creator>
<em:description>This Extension will help running site containing ActiveX content.</em:description>
<em:homepageURL>http://www.yoursite.com/</em:homepageURL>
</Description>
</RDF>



activeXsupporter.js
JavaScript
 function myExtension(evt) 
  {

alert('Extension Called');

var theFile = 'C:\Users\e3005531\Desktop\q.txt';
//create component for file writing
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath( theFile );
if(file.exists() == false) //check to see if file exists
{
    file.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
}
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
// use 0x02 | 0x10 to open file for appending.
//foStream.init(file, 0x02 | 0x10, 0666, 0);
foStream.init(file, 0x02 | 0x08 | 0x20, 0666, 0); 

// if you are sure there will never ever be any non-ascii text in data you can
// also call foStream.write(data, data.length) directly
var converter = Components.classes["@mozilla.org/intl/converter-output-stream;1"].createInstance(Components.interfaces.nsIConverterOutputStream);
converter.init(foStream, "UTF-8", 0, 0);
converter.writeString('Hi, This is Death. Who are you?');
converter.close(); // this closes foStream
alert('finished Writing');
}



document.addEventListener("MyExtensionEvent", myExtension, false, true);



activeXsupporter.xul

XML
<?xml version="1.0"?>
<overlay id="Scrapper-Overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><script type="application/x-javascript" src="chrome://activeXsupporter/content/activeXsupporter.js" />
</overlay>



My page's javascript Code

JavaScript
var element = document.createElement("MyExtensionDataElement");
       var ev = document.createEvent("Events");
       ev.initEvent("MyExtensionEvent", true, false);
       element.dispatchEvent(ev);




These are the codes m using.. But still i am unable to call this extension. Where am i doing wrong?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900