【发布时间】:2016-05-21 01:10:11
【问题描述】:
我查看了几个问题,这似乎是使用 iframe 打开页面的扩展程序的常见问题。我见过的一个解决方案是添加一个微调器 gif,并使用 for 循环在几秒钟后自动隐藏它。我试图这样做,但我无法让它工作。 gif 仅在 iframe 加载时出现(我单击扩展图标后 4 秒以上)
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_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"
}
}
如果我提出这个问题违反了任何规则,请在下面发表评论,我会更正我的问题。
【问题讨论】:
标签: javascript jquery html google-chrome plugins