wait for event
- From: hollex2108@xxxxxxxx
- Date: Tue, 20 May 2008 06:34:53 -0700 (PDT)
Hi,
I search for a method how my function detect an event while js is
carry out a loop.
I think it's not really important for a problem solving, but goodness
knows: I want to automate a web-application (GUI in html) from the
client-side. Therefor I use FireFox with xul.
I have several self defined js-objects. The object 'Main' control the
program flow. To control a dialog I use an object 'XYZDlg'. My object
'Browser' interact with a browser-control.
Now, for example, I want to extract data from a web-side (please see
what I basically write subsequent).
My problem is, that the function 'waitUntilPageIsLoaded' not work. If
I use a while-loop js never discover that the side is loaded. If I use
window.setTimeout/setIntervall instead of the loop, the function
'waitUntilPageIsLoaded' will be leaving before the side is loaded an
so the function 'getData' cause an error becaus the field with the
data exist not yet.
main.extractXYZData();
var Main = function() {
this.extractXYZData = function() {
xyzDlg.setSearchCriteria(value);
xyzDlg.search();
db.saveXYZData(XYZDlg.getData(););
}
}
var XYZDlg = function() {
this.setSearchCriteria= function(pValue) {
browser.setValueByID(IDSearchField, pValue);
}
this.search= function() {
browser.clickButton(IDSearchButton);
}
this.getData= function() {
return browser.getFieldValueByID(IDResultField);
}
}
var Browser= function() {
var PageIsLoaded=false;
waitUntilPageIsLoaded() = function() {
while (PageIsLoaded==false) {
//doEvents();
}
}
listObj.onStateChange = function(aProgress, aRequest, aFlag, aStatus)
{
save(CARRIAGE_RETURN + LINEFEED +'Browser.onStateChange()');
if (aFlag & listObj.wpl.STATE_START) {
PageIsLoaded=false;
// This fires when the load event is initiated
} else {
if (aFlag & listObj.wpl.STATE_STOP) {
if ( aFlag & listObj.wpl.STATE_IS_WINDOW ) {
// This fires when ALL load finish
}
if ( aFlag & listObj.wpl.STATE_IS_NETWORK ) {
// Fires when ALL load are REALLY
over,
PageIsLoaded=true;
}
}
}
return 0;
}
myBrowserControl.addProgressListener( listObj,
Components.interfaces.nsIWebProgress.NOTIFY_STATE_WINDOW );
this.setValueByID= function(pID, pValue) {
browser.getElementById(pID).value = pValue;
}
this.clickButton= function(pID) {
browser.getElementById(pID).click();
waitUntilPageIsLoaded();
}
this.getFieldValueByID= function(pID) {
return browser.getElementById(pID).value;
}
}
.
- Follow-Ups:
- Re: wait for event
- From: VK
- Re: wait for event
- Prev by Date: Re: JS 1.7 support: Who has it, etc.?
- Next by Date: Re: newbie question - how do you *require* a response?
- Previous by thread: newbie question - how do you *require* a response?
- Next by thread: Re: wait for event
- Index(es):