【发布时间】:2014-01-18 03:34:40
【问题描述】:
Chrome 应用有一个我想模拟的功能。本质上,manifest.json 调用了一个脚本 (main.js),该脚本会导致窗口以某种方式打开并调整 html 的大小。
所以不是直接加载html,而是应该在之前预加载并执行这个脚本,让应用感觉更加完整和封装。现在,当我侧加载应用程序(进行测试)时,我没有问题。但是当我去上传它时,我得到了一个错误。
现在,由于我知道这个清单和脚本可以侧载并在这个其他上传的应用程序上工作,我不知道我应该如何才能让它在没有错误的情况下上传。
An error occurred: Failed to process your item. background subsection of app section is not supported.
这是出现错误的清单部分:
"app": {
"background": {
"scripts": [ "main.js" ]
} },
有没有办法让这个脚本工作或通过其他方式获得它的效果?
这是 main.js 脚本:
/**
* Listens for the app launching then creates the window
*
* @see http://developer.chrome.com/trunk/apps/app.runtime.html
* @see http://developer.chrome.com/trunk/apps/app.window.html
*/
chrome.app.runtime.onLaunched.addListener(function() {
// Center window on screen.
var screenWidth = screen.availWidth;
var screenHeight = screen.availHeight;
var width = 1280;
var height = 720;
chrome.app.window.create('index.html', {
bounds: {
width: width,
height: height,
left: Math.round((screenWidth-width)/2),
top: Math.round((screenHeight-height)/2)
}
});
});
【问题讨论】:
标签: javascript resize window