Here, I am waiting for html button element from the popup iframe window. When a popup is open then my block of code will fire the click event on time and it's working fine, but my query is wanting to wait until not get button.
I have used the nested function calling with timeout thread, so when I call then work, but don't wait and go to the next task.
- setPrint();
- function setPrint() {
- setTimeout(function () {
- var btnprint = null;
- var frame = $('#WindowFadeiFrame').get(0).contentDocument;
- var btn = $('#btn', frame);
- if (btn.length == 0) {
- btnprint == null
- console.log('not found');
- }
- else {
- btn.click();
- btnprint = btn;
- console.log('found now');
- }
- if (btnprint == null) {
- setPrint(); }
- }, 100);
- }


Laxmidhar SahooRank #383 · 6.6K reputationPosted Jan 1, 2018, 8:40 PM EST
Mehul PrajapatiRank #6,843 · 255 reputationPosted Jan 1, 2018, 8:52 PM EST
Mehul PrajapatiRank #6,843 · 255 reputationPosted Jan 3, 2018, 11:23 PM EST