G
G
genesis11112019-05-07 18:22:17
Google Chrome
genesis1111, 2019-05-07 18:22:17

How to wait for DOM to load in chrome extension?

I am writing a browser extension and I ran into a difficulty - I need to open the url in a new tab and execute the script.

chrome.tabs.create({
         url: 'http://ooo.com',
         active: true,
       var sos = document.getElementById("id").children[0];
      });

As I understand it, the DOM of the page does not have time to load.
Please tell me how to wait for the page to load and make the var sos variable global (so that it can be used in another browser tab)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2019-05-08
@genezis1111

In general, the tab properties have a status field, which can be either loading or complete . Read the documentation carefully, everything is there.
The code you posted doesn't seem to be valid. How does it work for you in general?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question