EzhNotes

October 30, 2009

Override default firefox behavior from an extension

Filed under: programming — Tags: — alexezh @ 8:27 pm

There are number of ways to replace the default behavior for the firefox. If you want to replace a method on the object, following code will do the trick

eval("object.method =" + object[method].toString().replace('{', '{ your code here ;'));

In case if code is event handler for XUL object, you have to create a handler with the same event and return false to prevent further processing

  <binding id="my-id"
           extends="chrome://browser/content/id_to_extend">
    <handlers>
      <handler event="event to override">
      <![CDATA[
        your code here;

        return false;
      ]]></handler>
    </handlers>
  </binding>  

Create a free website or blog at WordPress.com.