getElementById not working in Google Chrome extension for <embed>

前端 未结 4 566
北海茫月
北海茫月 2021-01-07 12:52

In my Google Chrome extension content script I have the following:

jQuery(document).ready(function() {
    var player = document.getElementById(\'player\');
         


        
4条回答
  •  鱼传尺愫
    2021-01-07 13:33

    Turns out the problem was with timing. Even though it was inside a jQuery(document).ready(), the getElementById failed because the embed wasn't loaded yet. When I do a setTimeout of a few seconds, the getElementById works.

提交回复
热议问题