我是鉻應用程序編程和計算器的新手。多個響應<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;