Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Overlays only apply to XUL documents, not to XBL bindings (it is a XUL feature and not supported by XBL). While you <em>could</em> replace the binding for the <code>tabbrowser</code> element by your own that inherits from the original binding, the better solution to your problem would be overlaying the browser window to run your code in its context. That code would then modify the <code>tabbrowser</code> instance of the window. So in <code>chrome.manifest</code> you would write:</p> <pre><code>overlay chrome://browser/content/browser.xul chrome://dragdrop/content/browserOverlay.xul </code></pre> <p>And in <code>browserOverlay.xul</code>:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0"?&gt; &lt;overlay id="ondrop-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt; &lt;script type="application/x-javascript" src="browserOverlay.js"/&gt; &lt;/overlay&gt; </code></pre> <p>And finally, <code>browserOverlay.js</code> would look like this:</p> <pre class="lang-js prettyprint-override"><code>window.addEventListener("load", function(event) { var browser = window.getBrowser(); // Replace browser.onDrop method by own function but keep the original so that it // can be called later. var origOnDrop = browser.onDrop; browser.onDrop = function(aEvent, aXferData, aDragSession) { if (...) { // Your own processing of the call (start a search) ... } else { // Let the original function handle the call origOnDrop.apply(this, arguments); } }; }); </code></pre> <p>Note that the code above avoids using global variables, all variables are declared inside a function. This is generally a good course of action because you are running in the context of the browser window - any global variables are shared with the browser's own code and the code of other extensions also running in this context. Two pieces of code choosing the same name for their global variable could lead to nasty issues, not using any global variables is the best way to avoid this.</p> <hr> <p><strong>Edit</strong>: You were apparently looking at outdated code (Gecko 1.8 branch). The current code has no <code>onDrop</code> method but rather <a href="http://hg.mozilla.org/mozilla-central/file/e794cef56df6/browser/base/content/tabbrowser.xml#l3529" rel="nofollow">a proper event handler</a> on the tab container element. You cannot replace an event handler - but you also don't need to because it will not do anything if the text dragged isn't a link. So you can simply add your own event handler that will handle this case.</p> <pre class="lang-js prettyprint-override"><code>window.addEventListener("load", function(event) { var browser = window.getBrowser(); browser.tabContainer.addEventListener("drop", function(event) { if (...) { // This is a search string, do something with it ... // Indicate that we processed the event event.stopPropagation(); } }, false); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload