本文介绍了Chrome Packaged应用,始终位于顶部窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在编写一个文本编辑器,当我切换到浏览器或电子书阅读器软件时,我需要应用程序窗口始终位于顶部。据我所知,对于windows用户,chrome不提供任何解决方案。 或者我可以在应用程序中提供任何按钮来打开或关闭此功能? > 使用bg.js创建窗口的代码: var launch = function(){ chrome.app.window.create('index.html',{ type:'shell', width:440, height:680, minWidth:440, maxHeight:680, id:'paat-start'}); }; chrome.app.runtime.onLaunched.addListener(launch); chrome.commands.onCommand.addListener(launch); 感谢您的任何建议。 解决方案正如Ben Wells在上面提到的,现在可以通过 alwaysOnTop code> chrome.app.windows.create 中的$ c>选项。请注意, manifest.json 文件中需要特殊权限。示例: background.js chrome.app.window.create('window.html',{ alwaysOnTop:true,},function(appWindow){ //创建窗口并保持其他窗口。 //通过编程方式更改属性: //appWindow.setAlwaysOnTop(); }); manifest.json permissions:[alwaysOnTopWindows] 这似乎是在 issue 26427002 中添加的,在 issue 159523002 and issue 48113024 ,感谢社区! 我曾经考虑过这个问题,并希望对历史记录进行分类,文档中的一些不一致之处在于所需的permi名称ssion alwaysOnTop ,但是使用它会导致权限未知错误。 阅读有关此功能的原始提案,会使我转向 issue 326361 ,其中提到权限设置实际上称为 alwaysOnTopWindows 。然而,当时使用这个功能时,产生了一个需要谷歌浏览器开发通道或更新的错误(可能是因为该功能还不稳定)。 em 发现它来自浏览源代码,这两个权限可能是彼此的别名,但这可能是因为我不知道不完全了解Chromium代码库。 i am writing a text editor, i need the app window be always on top when switching to browser or e-book reader software. as i know ,for windows users, chrome doesn't provide any solution. is there any parameter to send when creating window to make window always on top?or can i provide any button in app to turn this feature on or off?Code i use to create window in bg.js:var launch = function () {chrome.app.window.create('index.html', { type: 'shell', width: 440, height: 680, minWidth: 440, maxHeight: 680, id: 'paat-start'});};chrome.app.runtime.onLaunched.addListener(launch);chrome.commands.onCommand.addListener(launch);thank for any suggestion. 解决方案 As Ben Wells mentioned above, this feature is now available in the stable release (either v33 or v34) via the alwaysOnTop option in chrome.app.windows.create. Note that special permissions are required in the manifest.json file. Example:background.jschrome.app.window.create('window.html', { alwaysOnTop: true,}, function (appWindow) { // Window created and will remain on top of others. // Change the property programmatically via: //appWindow.setAlwaysOnTop();});manifest.json"permissions": [ "alwaysOnTopWindows"]This seems to have been added in issue 26427002, gone stable in issue 159523002 and issue 48113024 thanks to the community!I had looked into this a while back and wanted to catalog my findings since historically there were some discrepancies in the documentation which previously stated the name of the required permission was alwaysOnTop, but using this caused a "permission is unknown" error.Reading through the original proposal for this feature lead me to issue 326361 which mentions the permission setting is actually called alwaysOnTopWindows. Using this one back then, however, yielded a "requires Google Chrome dev channel or newer" error (probably since the feature wasn't yet stable).I did find it peculiar from browsing the source code, these two permissions might be aliases of each other, but that might be because I don't fully understand the Chromium codebase. 这篇关于Chrome Packaged应用,始终位于顶部窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 01:45