I have tried the following but it still does not work.  However, the return
value of LoadURI is 0;
    nsCOMPtr<nsIWebNavigation>
spIWebNavigation1(do_QueryInterface(mRootDocShell));
    if (spIWebNavigation1)
    {
  nsCOMPtr<nsIURI> newUri;
  res = NS_NewURI(getter_AddRefs(newUri), sUrl);
      res = spIWebNavigation1->LoadURI(sUrl.get(),
nsIWebNavigation::LOAD_FLAGS_NONE);
//  res = spIWebNavigation1->GoBack();
    }

I got the mRoorDocShell from the following
    nsCOMPtr<nsIWindowMediator> windowMediator =
do_GetService(kWindowMediatorCID, &rv);
    if ( NS_SUCCEEDED( rv ) )
    {
        PRBool hasParentWindow = PR_FALSE;
        nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
        nsCOMPtr<nsIDOMWindow> content;
        nsCOMPtr<nsIXULWindow> xulWindow;
        if ( NS_SUCCEEDED(windowMediator->GetXULWindowEnumerator(nsnull,
getter_AddRefs(windowEnumerator))) )
        {
            // Get Each Dom window
            PRBool more;
            windowEnumerator->HasMoreElements(&more);
            while(more)
            {
                nsCOMPtr<nsISupports> nextWindow = nsnull;

                rv = windowEnumerator->GetNext(getter_AddRefs(nextWindow));
                if ( NS_SUCCEEDED( rv ) && nextWindow )
                {
                    xulWindow = do_QueryInterface(nextWindow);
                    if (xulWindow)
                    {
                        mXulWindow = xulWindow;
                        nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem;
                        nsCOMPtr<nsIDOMDocument> document;
                        nsCOMPtr<nsIDOMWindow> domWin;
                        nsCOMPtr<nsIWebBrowser> webBrowser;


xulWindow->GetPrimaryContentShell(getter_AddRefs(mShellAsTreeItem));

                        if (mShellAsTreeItem != nsnull)
                        {
                            nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
                            nsCOMPtr<nsIWidget> widget;
                            nsCOMPtr<nsIDocShell> rootDocShell
(do_QueryInterface(mShellAsTreeItem));
                            mRootDocShell = rootDocShell;

                            domWin = do_GetInterface(mShellAsTreeItem);

                            m_DomWin = domWin;
                            if (m_fIsDialog)
                            {
                                nsIScriptGlobalObject *pScript;
                                nsIDocShell *pDocShell;
                                m_TopDomWin->QueryInterface
(NS_GET_IID(nsIScriptGlobalObject), (void**) &pScript);
                                pScript->GetDocShell (&pDocShell);
                                mRootDocShell = pDocShell;
                            }

                            rv = DOMWindowToWidget(domWin,
getter_AddRefs(widget));
                            if ( NS_SUCCEEDED( rv ) && widget )
                            {
                                m_hWndCurrentDoc =
(HWND)widget->GetNativeData(NS_NATIVE_WINDOW);
                            }

                            rv =
domWin->GetDocument(getter_AddRefs(mDocument));
                        }

                        hasParentWindow = PR_TRUE;
                        break;
                    } // xulWindow
                }//next window
                windowEnumerator->HasMoreElements(&more);
            } // while
        }

"Pete Collins" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Doug Turner wrote:
> > Jacob Wong wrote:
> >
> >> I have tried to get the nsIWebBrowser using the following code
> >> nsCOMPtr<nsIWebBrowser>
> >>
pBrowser2(do_GetService("@mozilla.org/embedding/browser/nsWebBrowser;1"));
> >>
> >> nsCOMPtr<nsIWebNavigation> spIWebNavigation1 =
> >> do_QueryInterface(pBrowser2);
> >> nsCOMPtr<nsIURI> newUri;
> >> res = NS_NewURI(getter_AddRefs(newUri), sUrl);
> >> res = spIWebNavigation1->LoadURI(sUrl.get(),
> >> nsIWebNavigation::LOAD_FLAGS_NONE);
> >>
> >> However, Netscape 6.2.x does not load the new url.  the return value is
> >> 0x8000ffff.  That is unexpected error.  I also try to use
> >>
> >> res = spIWebNavigation1->GoBack();
> >>
> >> Netscape 6.2.x  does not go back to the previous page.
> >>
> >> Any idea what I have done wrong here?
> >>
> >
> > At what point do you make this call?  In your registerSelf callback?
> >
>
> It seems he wants his component to load a URI into a preloaded window in
> Netscape 6.2.
> So he would need to QI off an existing nsIDocShell or
> nsIDocShellTreeItem to do the load.
>
> --pete
>
>
>
>



Reply via email to