2017-02-28 71 views
0

我是鉻應用程序編程和計算器的新手。多個響應<webview>

我有,我想嵌入多個網站爲獨立的網頁視圖取決於用戶如何大,使應用程序窗口,自動秤,但也使每幅圖的比一個簡單的Chrome應用。這樣做無論在所有內容顯示中顯示應用的尺寸大小。

我可以得到它與一個webview與下面的代碼工作,但我不知道如何嵌入多個網站。

該圖顯示了我的理想場景。理想: enter image description here

的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; 

回答

0

更新!

我有超過1周的WebView工作和縮放,因爲我想要的。然而,正如我在原來的帖子中,我想在第二行的3個左右的網頁瀏覽,也與其他應用程序一樣隨着應用程序的擴展。這甚至有可能嗎?我是否必須在每個視圖中引用一定比例的應用程序?

的Index.html

<!DOCTYPE html> 
<html> 
<head> 
<style type="text/css"> 
    body { 
    margin: 2px; 
    } 
</style> 
</head> 
<body> 
<webview id="wv1" style="height:120px" src="http://www.google.com">   </webview> 

<webview id="wv2" style="height:420px; width:400px" src="http://www.google.com"></webview> 

<webview id="wv3" style="height:220px; width:400px" src="http://www.google.com"></webview> 

<webview id="wv4" style="height:190px; width:400px" src="http://www.google.com"></webview> 

main.js

function updateWebviews() { 
var webview = document.getElementById("wv1"); 
webview.style.width = document.documentElement.clientWidth + "px"; 
var webview = document.getElementById("wv2"); 
webview.style.width = document.documentElement.clientWidth + "px"; 
var webview = document.getElementById("wv3"); 
webview.style.width = document.documentElement.clientWidth + "px"; 
var webview = document.getElementById("wv4"); 
webview.style.width = document.documentElement.clientWidth + "px"; 
}; 
onload = updateWebviews; 
window.onresize = updateWebviews; 

請別人幫我才拋出自己關閉的橋樑!