0

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. Actually it's wait for iframe load. When iframe loads then popup opens up.

So i want to open popup when someone click on icon and show loader until the iframe load.

Thanks in advance.

Kapil Verma
  • 178
  • 3
  • 17
  • Just add the iframe in your js code that executes after page load. – wOxxOm Aug 24 '16 at 12:47
  • Wouldn't the iframe still have to load since it's contents are no part of the inital page? – roberrrt-s Aug 24 '16 at 12:57
  • Please check solution given in this related SO post - [chrome extension popup not open immediately](http://stackoverflow.com/a/10282986). – Teyam Aug 25 '16 at 17:13

1 Answers1

1

You need to define two functions showIcon and 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.

//html

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

//css

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