Is there a way to detect when the result of a JavaScript script have finished executing.
For example, if I have a (browser-side) Javascript function that fills in a text field, or submits a form, how do I know when the page is finished changing?
Again my only idea is to check the whole DOM tree with setInterval... but this seems quite tedious.
I execute a Javascript (say one that launches events).
Sometimes, this Javascript, for example, causes a new page to load, or causes new DOM elements to be created (clicking on the "Check" menu in Google Voice, or posting a Wall Post on Facebook).
I would like to know when all the _consequences_ of running my script have completed.
My simple idea:
* look at document.getElementsByTagName('*').length every 2 seconds (?)
* if it has not changed - we are done. otherwise, wait again
If I knew how to write a loop that would take many seconds to run,
the return would not return until the code is finished running.
I stand by my earlier example.
Perhaps you missed the crucial bit- if(myFunction()){alert('done')}
My challenge is actually to find whether my Javascript caused any DOM changes, and the only cross-browser way I believe to do this is to do a for loop that scans all elements...
Bookmarks