【发布时间】:2015-07-30 11:35:56
【问题描述】:
我正在尝试制作一个谷歌应用扩展程序,以加载具有应用程序无框架的外部网页。在程序启动时,页面加载需要几秒钟,并且它全是白色的。 无论我做什么,我都无法更改背景颜色。
波纹管是代码的一部分 有什么想法吗?
manifest.json
{
"name": "Stats ",
"description": "My Stats",
"manifest_version": 2,
"version": "1.0",
"icons": {
"128": "128.png"
},
"app": {
"background": {
"scripts": ["main.js"]
}
},
"permissions": [
"webview"
]
}
main.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create("index.html",
{ frame: "none",
id: "framelessWinID",
innerBounds: {
width: 360,
height: 300,
left: 600,
minWidth: 220,
minHeight: 220
}
}
);
});
index.html
<html>
<head>
<title>Stats</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script>
var wv = document.querySelector('webview');
wv.addEventListener('loadcommit', function() {
wv.insertCSS({
code: 'body { background: red !important; }',
runAt: 'document_start'
});
});
</script>
</head>
<body>
<div id="top-box" ></div>
<webview src="" style="width:500px; height:500px;" ></webview>
</body>
</html>
【问题讨论】:
标签: javascript webview google-chrome-app