我正在尝试开发一个始终在所有其他窗口(包括Chrome和其他应用程序)之上的Chrome应用程序。使用时我没有任何成功alwaysOnTop = true
。
什么谷歌的意思,当它说:
如果为true,则该窗口将保持在大多数其他窗口之上。如果有多个此类窗口,则当前聚焦的窗口将位于前景中。
这些“其他最多的窗口”是什么?我怎么知道这意味着什么窗口?到目前为止,一旦我离开该应用程序,它就不会停留在任何其他窗口之上。我把我的脚本放在下面,以防我错过了一些简单的事情。
function openApp() {
var innerBounds = {
left : 0,
top : 0.8 * screen.height,
width : screen.width,
height : 0.2 * screen.height,
};
var frame = {
type : "none",
};
var options = {
id : "lqps",
innerBounds : innerBounds,
frame : frame,
resizable : false,
alwaysOnTop : true,
visibleOnAllWorkspaces : true,
};
chrome.app.window.create("popup.html", options);
}
我希望有人能解决所有这些问题。
在manifest.json中,尝试以下操作:
"permissions": [
"identity",
"app.window.alwaysOnTop"
],
并在您的background.js中尝试:
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
id: 'mainWindow',
innerBounds: {
width: 260,
height: 190,
minWidth: 254,
maxWidth: 508,
minHeight: 190,
maxHeight: 190
},
frame:{
type: "chrome"
},
state: "normal",
hidden: false,
resizable: false,
alwaysOnTop: true
});
});
或仅仅是这样:
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
id: 'mainWindow',
alwaysOnTop: true
});
});
编辑,好吧,因为我正在做类似的事情,所以完成了以下操作以实现第二个弹出选项菜单:1.将上面的脚本添加到manifest.json中。2.格式化您的background.js类似于下面的我的:
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
id: 'mainWindow',
innerBounds: {
width: 260,
height: 190
},
frame:{
type: "chrome"
},
state: "normal",
hidden: false,
resizable: false,
alwaysOnTop: true
},
);
});
document.querySelector("#OptionsWin").addEventListener("click", optionWindow);
function optionWindow(){
chrome.app.window.create('options.html', {
id: 'optionsWindow',
innerBounds: {
width: 260,
height: 190
},
frame:{
type: "chrome"
},
state: "normal",
hidden: false,
resizable: false,
alwaysOnTop: true
}
);
}
<script src="background.js"></script>
如果将侦听器和函数放在另一个.js文件中,只要您将其位置包含在.html文件中,它也可以工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句