13
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

node-webkitでフルスリーン表示するには

Last updated at Posted at 2014-04-24

HTML5のフルスリーンAPIが使えない

WebRTCや、WebGLは使えるのにこれは意外でした。

でも大丈夫

HTML5のAPIで無いのはちょっと残念ですが、ちゃんとAPIが
用意されてます。

実装例

<!DOCTYPE html>
<html>
    <title>FullScreen Demo</title>
    <h1>FullScreen Demo</h1>
    We are using node.js <script>document.write(process.version)</script>.
<div id="hello"></div>
<button id="play">Full screen</button>
    <script>
    var gui = require('nw.gui');

    var btn = document.getElementById("play");
    btn.addEventListener("click", function () {
      // Get the current window
      var win = gui.Window.get();
      win.enterFullscreen();
    },false);
    window.addEventListener("load",function() {
      var gui = require('nw.gui');
      var win = gui.Window.get();
      win.enterFullscreen();
    });
    </script>
</html>

アドレスバー等が黙っていると表示されるので、

以下のような package.jsonで
windowのframeをfalseに指定する。

{
  "name": "nw-demo",
  "main": "index.html",
  "window": {
    "frame": false
  }
}

注意

OSXだと、特にフルスリーンから戻る処理を実装していなくても、OSのメニュー?で戻れますが、プラットフォームによっては困ったことになるかも

関連記事

13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?