How to check if the document is ready in JavaScript? -
i developing simulator simulate user actions in web page. in special case, there few number of buttons in page clicking on each changes content of page. programmatically click on each button , want extract new content added page. if have at:
http://www.elementbars.com/build-a-bar-service.aspx#
you can find example.
my code this:
for (var int i=0; i< buttonarray.length; i++){ // buttonarray array of buttons triggerclickevent(buttonarray[i]); extractnewcontent(); } function triggerclickevent (clickableelement) { jquery(clickableelement).trigger('click'); }
both triggerclickevent , extractnewcontent working, problem after triggering click event, javascript engine should wait while make sure new content added, not behave expected. example, noticed buttons clicked, extractnewcontent extracts content first button, meaning these 2 functions not working synchronously. used settimeout function, since not block execution, not resolve problem. used functions checking state of document, not working well.
i grateful if please me.
thanks.
the easiest way toolkit jquery. this:
jquery(document).ready(function() { ... });
or more concise
jquery(function() { });
part of problem "ready" not standardized across browsers. toolkits jquery make that.
Comments
Post a Comment