[Project_owners] getBrowserForDocument()

HJ bugs4hj at netscape.net
Sat Feb 7 10:53:18 EST 2004


Heya guys,

MultiZilla replaces getBrowserForDocument() in navigator.js and I wonder if there's a better way. This is what we use:

function getBrowserForDocument(aDocument)
{  
  var browsers = getBrowser().browsers;

  for (var i = 0; i < browsers.length; i++) {
    if (browsers[i].contentDocument == aDocument)
      return browsers[i];
    else if (_content.frames.length) {
      for (var frame_nr = 0; frame_nr < _content.frames.length; frame_nr++) {
        if (_content.frames[frame_nr].length) { // deep nested
          if (isFrameDocumentContainer(_content.frames[frame_nr], aDocument))
            return browsers[i];
        }
        if (_content.frames[frame_nr].document == aDocument)
          return browsers[i];
      }
    }
  }
  return null;
}

function isFrameDocumentContainer(aFrame, aDocument)
{
  if (!aFrame || !aDocument)
    return false;

  for (var i = 0; i < aFrame.length; i++) {
    if (aFrame.frames[i].length) {
      if (isFrameDocumentContainer(aFrame, aDocument)) // recursive call
        return true;
    }
    if (aFrame.frames[i].document == aDocument)
      return true;
  }
  return false;
}

P.s. I would like to see this fixed in mozilla
/HJ

__________________________________________________________________
New! Unlimited Netscape Internet Service.
Only $9.95 a month -- Sign up today at http://isp.netscape.com/register
Act now to get a personalized email address!

Netscape. Just the Net You Need.


More information about the Project_owners mailing list