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

编程入门 行业动态 更新时间:2024-10-28 04:18:24
本文介绍了显示Chrome扩展程序弹出窗口后如何触发事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

< html> < head> < script type =text / javascriptsrc =./ plugin.js>< / script> < script type =text / javascript> $(document).ready(function(){ plugin.init(); plugin.getData(); }); < / script> < / head> < body> ...< / body> < / html>

是否有一个事件可以在 Chrome呈现弹出窗口?我曾尝试用身体内的div的可见性事件来瞎搞,但除了处理document.ready,我还没有能够自动触发这些事件,这导致了相同的行为。

<$ p $ p> < HTML> < head> < script type =text / javascriptsrc =./ plugin.js>< / script> < script type =text / javascript> $(document).ready(function(){ plugin.init(); setTimeout(plugin.getData); }); < / script> < / head> < body> ...< / body> < / html>

我已经在自己的扩展中完成了这个工作, p>

I am using jQuery with a Google Chrome extension popup. The pop-up page uses jQuery's 'document.ready' event to trigger a request to a web service. The problem is that the pop-up does not render until a response is received, which makes it seem unresponsive. Here's an outline of the page:

<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>

Is there an event I can use to trigger 'getData()' after Chrome renders the pop-up? I have tried monkeying with visibility events of divs within the body, but I haven't been able to trigger these events automatically other than by handling document.ready, which leads to the same behavior.

解决方案

Use setTimeout with no delay:

<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>

I've done this in an extension of my own, and it should do the trick.

更多推荐

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

本文发布于:2023-08-06 05:17:30,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:弹出窗口   事件   程序   Chrome

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!