Skip to content

Commit 985b4b3

Browse files
Gil Mizrahipaf31
authored andcommitted
busy wait on body for iframe to load (#70)
1 parent a8eca29 commit 985b4b3

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

js/index.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -276,18 +276,17 @@ $(function() {
276276
script.appendChild(iframe.createTextNode(scripts));
277277

278278
$('iframe').ready(function() {
279+
var checkExists = setInterval(function() {
280+
var body = iframe.getElementsByTagName('body')[0];
281+
if (body) {
282+
body.onclick = function() {
283+
hideMenus();
284+
};
285+
body.appendChild(script);
286+
clearInterval(checkExists);
287+
}
288+
}, 100);
279289

280-
var body = iframe.getElementsByTagName('body')[0];
281-
282-
body.onclick = function() {
283-
hideMenus();
284-
};
285-
286-
if (body) {
287-
body.appendChild(script);
288-
} else {
289-
console.log("<body> element is missing!");
290-
}
291290
});
292291

293292
};

0 commit comments

Comments
 (0)