I've looked at a few questions and it seems this is a common problem for extensions that open pages with iframes. A solution i've seen is to add a spinner gif and have it hide automatically after a few seconds using a for loop. I tried to do that and i couldnt get it to work. The gif only appears when the iframe has loaded (4+ seconds after i clicked the extension icon)
HTML:
<!--
<!doctype html>
This page is shown when the extension button is clicked, because the
"browser_action" field in manifest.json contains the "default_popup" key with
value "popup.html".
-->
<html>
<head>
<title>Google</title>
<style>
html, body {
margin:0;
padding:0;
}
body {
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
font-size: 100%;
background-color: white;
overflow-y:hidden;
}
#status {
/* avoid an excessively wide status text */
white-space: pre;
text-overflow: ellipsis;
overflow: hidden;
max-width: 400px;
}
p{
visibility:visible;
}
</style>
<!--
- JavaScript and HTML must be in separate files: see our Content Security
- Policy documentation[1] for details and explanation.
-
- [1]: https://developer.chrome.com/extensions/contentSecurityPolicy
-->
<script src="popup.js"></script>
</head>
<body>
<div id="status">
<img src="spinner.gif"/>
<iframe src="https://www.google.com/" width="398" height="100%" frameborder="0"></iframe>
</body>
</html>
js:
for (var i = 1; i == 10; i++) {
document.getElementById(img).style.visibility = "hidden";
}
Manifest file:
{
"manifest_version": 2,
"name": "Open google",
"version": "1",
"browser_action": {
"default_icon": {
"19": "icon.png",
"38": "icon.png"
},
"default_title": "Webpage opener",
"default_popup": "popup.html"
}
}
If i've broken any rules by asking this question, please comment below and i'll correct my question.