开发者

Xulrunner Displaying iframe link target in status a bar

开发者 https://www.devze.com 2023-03-11 22:49 出处:网络
I have an xulrunner application that contains an iframe element. When the user hovers the mouse over a link in the framed document, I want to display the target url in another element.

I have an xulrunner application that contains an iframe element. When the user hovers the mouse over a link in the framed document, I want to display the target url in another element.

I can catch mousemove events with: iframe.addEventListener('mousem开发者_运维知识库ove', function() { ... }, false);

but I don't see how to query the iframe for the url under the mouse. Can this be done?


I solved this problem using code I found here:

http://developerfriendly.googlecode.com/svn/trunk/mozilla/xulrunner/WebRunner_app/Contents/Resources/chrome/content/webrunner.js

Specifically I did this:

var gXULBrowserWindow =
{
  QueryInterface: function(aIID)
  {
    if (aIID.Equals(Components.interfaces.nsIXULBrowserWindow) ||
        aIID.Equals(Components.interfaces.nsISupports))
     return this;

    throw Components.results.NS_NOINTERFACE;
  },

  setJSStatus: function() { },
  setJSDefaultStatus: function() { },

  setOverLink: function(msg, aLink)
  {
    var sb = GetOptElem('bottomstatus');
    if(sb)
        sb.label = msg;
  }
};
// hookup the browser window callbacks
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
    .getInterface(Components.interfaces.nsIWebNavigation)
    .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
    .treeOwner
    .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
    .getInterface(Components.interfaces.nsIXULWindow)
    .XULBrowserWindow = gXULBrowserWindow;
0

精彩评论

暂无评论...
验证码 换一张
取 消