Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Sun, 28 May 2006 12:31:30 -0400,    group: microsoft.public.inetsdk.programming.html_objmodel        back       


ReadyState and Remote Callbacks   
Ok. For starters I'm using the .net 2.0 WebBrowser control to get the handles on the native COM interfaces. If this is 'bad' I'd like to know. The app hosting the IE instance is a .net application so it made sense to just take this shortcut into the DOM. That said, if there is something I don't know about this shortcut, I'm all ears.

Ok. So here is a chunk of code.

#region find the next page button and click it.

foreach (Object o in window.document.all)
{
    if ((o as IHTMLElement) == null)
    {
        _log.AppendText(String.Format("Unknown: {0}\n", o.ToString()));
        continue;
    }

IHTMLElement element = (IHTMLElement)o;

if ((element.tagName != null) &&
    (element.tagName.ToLower() == "a"))
    {
        if ((element.id != null) &&
            (element.id.ToLower().Trim() == "gotonextbutton"))
        {
            HTMLAnchorElement anchor = (HTMLAnchorElement)element;

            result.NextAnchor = anchor;
        }
    }
}

#endregion

(sidenote: i know i could just call get elementbyid to get the same anchor, but there is other code left out that does anchor sniffing of anchors with no id.)

Ok. So what I'm doing is getting a page of data and parsing it, then finding the next button. The parsed data and the next button are returnered from this function in a result class. The automation controllers looks at the data and the next button to make a decision about whether or not more pages exist and if it does the button is clicked.

if (result.NextAnchor != null)

{

result.NextAnchor.click();

DateTime endTime = DateTime.Now.AddSeconds(4);

while (DateTime.Now < endTime)

{

Application.DoEvents();

}

}

Now my question is how do I get rid of that 4 second hack I wrote in to allow for loading pages of data via AJAX technologies? With a normal call to navigate, I can depend on the ready state of the browser and the eventing model to ensure that a page has completed load. However in a loaded page that is making data updates and UI via scrpiting how can I hook a 'ready state'?

Is it possible to hook when a javascript function returns? That's one possibility for this particular scenario.



Thanks,

Paul
date: Sun, 28 May 2006 12:31:30 -0400   author:   Paul D. Murphy

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us