IEModule_DocumentComplete2 event getting rootDocLoaded false while refresh

Add-in Express™ Support Service
That's what is more important than anything else

IEModule_DocumentComplete2 event getting rootDocLoaded false while refresh
 
ravinukala




Posts: 103
Joined: 2012-10-05
Hi,

I have developed IE bar where I am injecting some script in page in IEModule_DocumentComplete2 event

like this

private void IEModule_DocumentComplete2(object pDisp, string url, bool rootDocLoaded)
{
if (rootDocLoaded)
{
oRIEBar.DocumentCompleted(url);
}
}

Problem is, I am getting rootDocLoaded false when I refresh the browser.

Please help.

Regards
Posted 08 Jan, 2013 07:41:19 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Ravi,

What do you get in the 'url' parameter? Probably the browser refreshes iframes only.
Posted 08 Jan, 2013 08:16:44 Top
ravinukala




Posts: 103
Joined: 2012-10-05
Hi,

Yes, the browser refreshes iframes only. Now how can I come to now that all iframes/frames are loaded completely.

All my functionality is working fine for first load. It gives access denied error when user refreshes the browser.

Regards
Posted 09 Jan, 2013 00:16:19 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Ravi,

Now how can I come to now that all iframes/frames are loaded completely.

When the document is completely loaded, the 'ReadyState' property of the browser returns 'READYSTATE_COMPLETE'.

It gives access denied error when user refreshes the browser.

The fact is that the 'pDisp' parameter may return the iframe document. In this case you need to use the 'HTMLDocument' property to access the HTML DOM when you inject the script.
Posted 09 Jan, 2013 02:28:20 Top
ravinukala




Posts: 103
Joined: 2012-10-05
Hi,

IEApp.ReadyState is always READYSTATE_INTERACTIVE when I refresh the browser.

You can check url:
http://safsdev.sourceforge.net/Default.htm
Posted 09 Jan, 2013 02:37:59 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Ravi,

Here is the solution for this web page:


private Timer timer = new Timer();

        private void IEModule_OnConnect(object sender, int threadId)
        {
            timer.Interval = 300;
            timer.Tick += new EventHandler(timer_Tick);
        }

        void timer_Tick(object sender, EventArgs e)
        {
            if (IEApp.ReadyState == IE.tagREADYSTATE.READYSTATE_COMPLETE)
            {
                timer.Enabled = false;
                InjectScript(IEApp);
            }
        }

        private void IEModule_DocumentComplete2(object pDisp, string url, bool rootDocLoaded)
        {
            if (rootDocLoaded)
            {
                if (pDisp is IE.WebBrowser)
                    InjectScript((IE.WebBrowser)pDisp);
            }
        }

        private void IEModule_OnBeforeRefresh(object sender, ADXIEBeforeRefreshEventArgs e)
        {
            timer.Enabled = true;
        }

        private void InjectScript(IE.WebBrowser browser)
        {
            Debug.WriteLine("InjectScript: " + browser.LocationURL);
        }


To activate the 'OnBeforeRefresh' event you need to set the 'HandleDocumentUICommands' property of the iemodule to true.
Posted 09 Jan, 2013 08:43:44 Top