chrome extension popup not open immediately

痞子三分冷 提交于 2019-12-30 11:34:15

问题


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?


回答1:


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?




回答2:


i have seen this behavior before when you have a long running ajax call that you are doing on popup load.. hard to tell further without code samples or description of what you are doing



来源:https://stackoverflow.com/questions/8802789/chrome-extension-popup-not-open-immediately

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!