简体   繁体   English

如何在 chrome 扩展弹出窗口中添加加载程序?

[英]How to add loader in chrome extension popup?

I am developing chrome extension and loading iframe in that the problem is when i am clicking on the extension icon it's taking time to show popup.我正在开发 chrome 扩展并加载 iframe,因为问题是当我点击扩展图标时,它需要时间来显示弹出窗口。 Actually it's wait for iframe load.实际上它是等待 iframe 加载。 When iframe loads then popup opens up.当 iframe 加载然后弹出窗口打开。

So i want to open popup when someone click on icon and show loader until the iframe load.所以我想在有人点击图标时打开弹出窗口并显示加载程序直到 iframe 加载。

Thanks in advance.提前致谢。

You need to define two functions showIcon and hideIcon.您需要定义两个函数 showIcon 和 hideIcon。

function showIcon() {
   document.getElementById('loading').style.display ='block';
 } 

 function hideIcon() {
   document.getElementById('loading').style.display ='none';
 }

You execute showIcon when making the xhr request and then call hideIcon when xhr returns.您在发出 xhr 请求时执行 showIcon,然后在 xhr 返回时调用 hideIcon。

//html //html

<div id="loading">Loading</div>

//css //css

#loading{
text-indent:-9999px
background-image:url('loading.gif');
display:none;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM