我是铬应用程序编程和计算器的新手。多个响应<webview>
我有,我想嵌入多个网站为独立的网页视图取决于用户如何大,使应用程序窗口,自动秤,但也使每幅图的比一个简单的Chrome应用。这样做无论在所有内容显示中显示应用的尺寸大小。
我可以得到它与一个webview与下面的代码工作,但我不知道如何嵌入多个网站。
的manifest.json { “名” 的 “Hello World!”, “说明”: “我的第一个Chrome应用。”, “版本”: “0.1”, “manifest_version” :2, “权限”:[ “web视图”], “图标”:{ “128”:为 “logo.png” }, “应用程序”:{ “背景”:{ “脚本”: [ “background.js”] } } }
个background.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
bounds: {
'width': 1380,
'height': 1700
}
});
})
的index.html
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
margin: 0px;
}
</style>
</head>
<body>
<webview id="wv1" src="http://www.google.com"></webview>
<script src="main.js"></script>
</body>
</html>
main.js
function updateWebviews() {
var webview = document.querySelector("webview");
webview.style.width = document.documentElement.clientWidth + "px";
};
onload = updateWebviews;
window.onresize = updateWebviews;