alwaysOnTop Google 是什么意思?
What does Google mean by alwaysOnTop?
我正在尝试开发一个 Chrome 应用程序,它始终位于所有其他 windows 之上,包括 Chrome 和其他应用程序。我在使用 alwaysOnTop = true
.
时没有取得任何成功
google 是什么意思:
If true, the window will stay above most other windows. If there are multiple windows of this kind, the currently focused window will be in the foreground.
这些 "most other windows" 是什么?我怎么知道 windows 是什么意思?到目前为止,一旦我离开应用程序,它就不会停留在任何其他 windows 之上。我已将我的脚本放在下面,以防它是我错过的简单内容。
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
}
);
}
- 现在在你的 HTML 文件中确保添加:
<script src="background.js"></script>
如果将侦听器和函数放在另一个 .js 文件中,只要将其位置包含在 .html 文件中,这也适用。
- 一些代码编辑器可能会在测试代码时提供问题,最好使用浏览器扩展启动进行测试,或者我已经找到 "Chrome Dev Editor" 和良好的编码平台来启动应用程序(不是那么多用于发布但是,必须手动执行此操作)。因此,如果 windows 没有遵守预期的功能,请尝试 Chrome Dev Editor。
我正在尝试开发一个 Chrome 应用程序,它始终位于所有其他 windows 之上,包括 Chrome 和其他应用程序。我在使用 alwaysOnTop = true
.
google 是什么意思:
If true, the window will stay above most other windows. If there are multiple windows of this kind, the currently focused window will be in the foreground.
这些 "most other windows" 是什么?我怎么知道 windows 是什么意思?到目前为止,一旦我离开应用程序,它就不会停留在任何其他 windows 之上。我已将我的脚本放在下面,以防它是我错过的简单内容。
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
}
);
}
- 现在在你的 HTML 文件中确保添加:
<script src="background.js"></script>
如果将侦听器和函数放在另一个 .js 文件中,只要将其位置包含在 .html 文件中,这也适用。
- 一些代码编辑器可能会在测试代码时提供问题,最好使用浏览器扩展启动进行测试,或者我已经找到 "Chrome Dev Editor" 和良好的编码平台来启动应用程序(不是那么多用于发布但是,必须手动执行此操作)。因此,如果 windows 没有遵守预期的功能,请尝试 Chrome Dev Editor。