admin管理员组文章数量:1422048
I would like my Chrome app to open so it's touching the task bar and just offset from the right of the screen.
My current code:
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('window.html', {
'bounds': {
'width': 300,
'height': 325
},
'resizable': false,
frame: 'none'
});
});
I would like my Chrome app to open so it's touching the task bar and just offset from the right of the screen.
My current code:
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('window.html', {
'bounds': {
'width': 300,
'height': 325
},
'resizable': false,
frame: 'none'
});
});
Share
Improve this question
edited Jan 29, 2015 at 21:57
Xan
77.7k18 gold badges197 silver badges217 bronze badges
asked Jan 29, 2015 at 21:27
user2242044user2242044
9,26329 gold badges105 silver badges172 bronze badges
5
- That's not even valid JavaScript. – Xan Commented Jan 29, 2015 at 21:38
- @Xan I know. I'm looking for some help. – user2242044 Commented Jan 29, 2015 at 21:49
- What kind of help you need and will be useful depends on your current level of knowledge. So far, not great. Can you at least make some code that runs, even if it does not do what you want? I mean, this code is one big syntax error. – Xan Commented Jan 29, 2015 at 21:50
- @xan My knowledge is limited. I cut out the code that had issue. This loads my extension in the center of the screen. – user2242044 Commented Jan 29, 2015 at 21:52
- Edited your question a bit. Note: chrome apps are not the same as extensions; fixed the title and tags – Xan Commented Jan 29, 2015 at 21:57
1 Answer
Reset to default 4If you're okay with setting the outer bounds, that is, the full window size (and the content is potentially smaller), then it's simple:
chrome.app.runtime.onLaunched.addListener(function() {
var windowWidth = 300;
var windowHeight = 325;
chrome.app.window.create('window.html', {
outerBounds: { // 'bounds' is deprecated, and you want full window size
width: windowWidth,
height: windowHeight,
left: screen.availWidth - windowWidth,
top: screen.availHeight - windowHeight,
},
resizable: false,
frame: 'none'
});
});
If you want to set inner bounds, that is the exact size of the window content, then you can't predict the size of the window accurately. You'll have to first create it and then reposition it in the callback:
chrome.app.runtime.onLaunched.addListener(function() {
var windowWidth = 300;
var windowHeight = 325;
chrome.app.window.create(
'window.html',
{
innerBounds: {
width: windowWidth,
height: windowHeight
},
resizable: false,
frame: 'none'
},
function(win) {
win.outerBounds.setPosition(
screen.availWidth - win.outerBounds.width, // left
screen.availHeight - win.outerBounds.height // top
);
}
);
});
All in all, it'a a good idea to review the actual documentation of chrome.app.window
API.
本文标签: javascriptGetting a Chrome app window to open at the bottom right of screenStack Overflow
版权声明:本文标题:javascript - Getting a Chrome app window to open at the bottom right of screen - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745357791a2655155.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论