DocumentLoaded executes every time any frame or iframe etc on page is
loaded. the way to check, wheather there was a main document loaded
was described at WinEmbed (or MFCEmbed, or somewhere else)

<PRE>NS_IMETHODIMP CBrowserWnd<B><FONT COLOR="#663300">::</FONT></
B>OnLocationChange<B><FONT COLOR="#663300"> (</FONT></B>
nsIWebProgress<B><FONT COLOR="#663300">*</FONT></B>
aWebProgress<B><FONT COLOR="#663300">,</FONT></B> nsIRequest<B><FONT
COLOR="#663300">*</FONT></B> aRequest<B><FONT COLOR="#663300">,</
FONT></B> nsIURI<B><FONT COLOR="#663300"> *</FONT></B>location<B><FONT
COLOR="#663300"> )
{</FONT></B><FONT COLOR="#FF0000">

    bool</FONT> isSubFrameLoad<B><FONT COLOR="#663300"> =</FONT></
B><B><FONT COLOR="#000000"> false</FONT></B><B><FONT
COLOR="#663300">;</FONT></B><I><FONT COLOR="#999999"> // Is this a
subframe load

</FONT></I><FONT COLOR="#FF0000">    if</FONT><B><FONT
COLOR="#663300"> (</FONT></B> aWebProgress<B><FONT COLOR="#663300"> )
    {</FONT></B>
        nsCOMPtr<B><FONT COLOR="#663300">&amp;</FONT></B>lt<B><FONT
COLOR="#663300">;</FONT></B>nsIDOMWindow<B><FONT
COLOR="#663300">&amp;</FONT></B>gt<B><FONT COLOR="#663300">;</FONT></
B>  domWindow<B><FONT COLOR="#663300">;</FONT></B>

        nsCOMPtr<B><FONT COLOR="#663300">&amp;</FONT></B>lt<B><FONT
COLOR="#663300">;</FONT></B>nsIDOMWindow<B><FONT
COLOR="#663300">&amp;</FONT></B>gt<B><FONT COLOR="#663300">;</FONT></
B>  topDomWindow<B><FONT COLOR="#663300">;</FONT></B>
        aWebProgress<B><FONT COLOR="#663300">-&amp;</FONT></
B>gt<B><FONT COLOR="#663300">;</FONT></B>GetDOMWindow<B><FONT
COLOR="#663300"> (</FONT></B> getter_AddRefs<B><FONT COLOR="#663300">
(</FONT></B> domWindow<B><FONT COLOR="#663300"> ) );</FONT></B><FONT
COLOR="#FF0000">

        if</FONT><B><FONT COLOR="#663300"> (</FONT></B>
domWindow<B><FONT COLOR="#663300"> )
        {</FONT></B>
            domWindow<B><FONT COLOR="#663300">-&amp;</FONT></
B>gt<B><FONT COLOR="#663300">;</FONT></B>GetTop<B><FONT
COLOR="#663300"> (</FONT></B> getter_AddRefs<B><FONT COLOR="#663300">
(</FONT></B> topDomWindow<B><FONT COLOR="#663300"> ) );
        }</FONT></B>

        isSubFrameLoad<B><FONT COLOR="#663300"> =</FONT></B>
PR_TRUE<B><FONT COLOR="#663300"> == (</FONT></B> domWindow<B><FONT
COLOR="#663300"> !=</FONT></B> topDomWindow<B><FONT
COLOR="#663300"> );
    }</FONT></B><FONT COLOR="#FF0000">


    if</FONT><B><FONT COLOR="#663300"> ( !</FONT></
B>isSubFrameLoad<B><FONT COLOR="#663300"> )
    {</FONT></B><I><FONT COLOR="#999999">
        //main frame load
</FONT></I>        nsCAutoString autoBuffer<B><FONT COLOR="#663300">;</
FONT></B>
        location<B><FONT COLOR="#663300">-&amp;</FONT></B>gt<B><FONT
COLOR="#663300">;</FONT></B>GetPath<B><FONT COLOR="#663300"> (</FONT></
B> autoBuffer<B><FONT COLOR="#663300"> );</FONT></B><FONT
COLOR="#990000">

        const</FONT> nsACString<B><FONT COLOR="#663300">::</FONT></
B>char_type<B><FONT COLOR="#663300"> *</FONT></B>url<B><FONT
COLOR="#663300"> =</FONT></B> autoBuffer<B><FONT COLOR="#663300">.</
FONT></B>get<B><FONT COLOR="#663300"> ();
    }</FONT></B><FONT COLOR="#FF0000">

    return</FONT> NS_OK<B><FONT COLOR="#663300">;
}</FONT></B></PRE>

_______________________________________________
dev-embedding mailing list
dev-embedding@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to