如何在显示Chrome扩展程序弹出窗口后触发事件?

And*_*eiM 2 jquery google-chrome google-chrome-extension

我正在使用带有Google Chrome扩展弹出窗口的jQuery.弹出页面使用jQuery的'document.ready'事件来触发对Web服务的请求.问题是弹出窗口在收到响应之前不会呈现,这使得它看起来没有响应.这是页面的大纲:

<html>
<head>
    <script type="text/javascript" src="./plugin.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            plugin.init();            
            plugin.getData();
        });        
    </script>
</head>
<body>...</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Chrome呈现弹出窗口后,是否有可用于触发'getData()'的事件?我已经尝试使用body中的div的可见性事件进行monkeying,但除了处理document.ready之外,我还没有能够自动触发这些事件,这会导致相同的行为.

Håv*_*ard 6

使用setTimeout没有延迟:

<html>
<head>
    <script type="text/javascript" src="./plugin.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            plugin.init();            
            setTimeout(plugin.getData);
        });        
    </script>
</head>
<body>...</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我已经在我自己的扩展中做到了这一点,它应该做到这一点.