使用javascript检测不同操作系统的窗口的标题栏高度 [英] detect the the title bar height for a window for different operating systems with javascript

查看:79
本文介绍了使用javascript检测不同操作系统的窗口的标题栏高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用自己的窗口在chrome应用程序中制作画布游戏.我使用window.onResize使用窗口的大小调整了游戏的大小.由于我的游戏是采用8位样式制作的,因此我不希望默认窗口大小具有模糊的像素,因为它会被部分调整大小.

I am making a canvas game in a chrome app with it's own window. I made my game resize with the window's size using window.onResize. Since my game is made with an 8-bit style, I don't want the default window size to have blurry pixels because it is partially resized.

我知道您可以在background.js文件中指定窗口的大小,但是当窗口打开时,窗口的大小包括标题栏.

I am aware that you can specify the window's size in the background.js file, but when the window opens, the size of the window includes the title bar.

基本上,我希望游戏高度为400px,但是我只能设置窗口高度.标题栏包含在窗口高度中,因此具有不同标题栏高度的不同操作系统将影响游戏高度的大小.我需要一种方法来检测background.js中操作系统标题栏的高度.

Basically, I want the game height to be 400px, but I can only set the window height. The title bar is included in the window height, so different operating systems with different title bar heights will affect the size of the game height. I need a way to detect the height of the operating systems title bar height in background.js.

推荐答案

要完全控制应用程序的窗口大小,请创建一个无框窗口,该窗口没有任何内置装饰,请自己绘制所有内容.

To fully control window size of the app create a frameless window that won't have any built-in decorations, draw everything yourself.

chrome.app.runtime.onLaunched.addListener(function() {
    chrome.app.window.create("window.html", {  
         frame: "none",
         .............
    });
});

chrome.app.window API文档提供了

chrome.app.window API documentation provides a sample app, here's a screenshot:

这篇关于使用javascript检测不同操作系统的窗口的标题栏高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆