2017-02-28 70 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; 

请别人帮我才抛出自己关闭的桥梁!