+ 2

JavaScript wait for an element to load

I'm writing an automation extension for Mozilla and I have an issue. How do you sleep script after executing click event, so that new elements can load. If I try putting setTimeout in recursion, ie if element is null, go back to the start of function after x time, this causes browser to hang. I'm testing in a scratchpad so I'm not sure how to import modules.

1st Feb 2018, 3:17 PM
Manvydas Kriauciunas
Manvydas Kriauciunas - avatar
1 Resposta
+ 4
If it opens a new window when you click on it you can use window.onload = someFunction()
3rd Feb 2018, 11:33 PM
Ole113
Ole113 - avatar