0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Web 向けウィンドウマネージャの WinBox.js を使ってみた

Posted at

WinBox.js

WinBox.js は Web ページ内でウィンドウマネージャを実現するライブラリで、ウィンドウを開いてウィンドウ内にコンテンツを表示することができる。

シンプルなウィンドウの表示

new WinBox({title: {title}, html: {html}}) でウィンドウを表示することができる。

test1.png

test1.html
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; utf-8" />
    <title>WinBox test 1</title>
    <script src="winbox.bundle.min.js"></script>
  </head>
  <body style="background-color: #888888;">
    <script>
      const win = new WinBox({
        title: "Window",
        html: "<h1>h1 text</h1><div>div text</div>",
      });
    </script>
  </body>
</html>

ウィンドウサイズの調整

width, height でウィンドウのサイズを指定することができる。

const win1 = new WinBox({
  title: "Window 1",
  html: "<h1>h1 text</h1><h2>h2 text</h2><div>div</div>",
  width: 200,
  height: 250,
});

ウェブページの表示

URL を指定すると、その URL をウィンドウ内に表示することができる。

const win2 = new WinBox({
  title: "Window 2",
  url: "content1.html",
  width: 200,
  height: 100,
});
content1.html
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; utf-8" />
    <title>content1.html</title>
  </head>
  <body style="background-color: #dddddd;">
    <div id="text1">text 1</div>
    <div id="text2"></div>
    <script>
      const tag = document.getElementById("text2");
      tag.innerText = "text 2";
    </script>
  </body>
</html>

content1.html には JavaScript も記述されているが、JavaScript も実行される。

ウィンドウの最小化

minimize() で最下部にウィンドウをたたむことができる。

const win3 = new WinBox({
  title: "Window 3",
}).minimize();

test2.png

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?