Chrome扩展弹出式菜单不会立即打开 [英] chrome extension popup not open immediately

查看:145
本文介绍了Chrome扩展弹出式菜单不会立即打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我第一次点击浏览器动作按钮 - 一切顺利。



当我点击浏览器动作按钮第二次,几分钟后没有点击它,它需要超过10秒,直到显示弹出。



我试着在后台注释掉所有的周期性方法,并弹出load事件中的所有方法,但它仍然不会立即显示。



有什么建议吗?

解决方案

当我向弹出窗口添加iframe时,弹出类似的问题。 Chrome将等待显示弹出窗口,直到iframe加载完成。



对我来说,修正包装了将iframe添加到HTML中的代码:

  setTimeout(function(){
// Code here
},0);

通过这种方式,Chrome首先显示了弹出窗口,然后从加载iframe开始。



也许你有类似的问题?


I'm writing a chrome extension.

When i click the browser action button in the first time - all goes well.

When i click the browser action button the second time, after several minutes of not clicking it, it takes more than 10 seconds until the popup is shown.

I've tried commenting out all of the periodic methods in the background and all of the methods in the load event of the popup, but it still doesn't shown immediately.

any suggestions?

解决方案

I had a similar issue with the popup when I was adding an iframe to the popup. Chrome would wait with showing the popup until that iframe was loaded.

For me the fix was wrapping the code that added the iframe to the HTML in:

setTimeout(function(){
    // Code here
},0);

This way Chrome showed the popup first, after which it begin with loading the iframe.

Maybe you have a similar problem?

这篇关于Chrome扩展弹出式菜单不会立即打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆