LoginSignup
1
2

More than 5 years have passed since last update.

window.openで開いたウィンドウを右のモニターに出す

Posted at

Firefox Quantum (ver57) ubuntu 17.10 で確認

方法1. 開くときに座標指定

a.html
<script>
function wopen(url){
        //現在使用しているモニターの横幅を取得
        var left = window.parent.screen.width;
        //開く (width,heightを右モニターより大きい値だとモニタ内に全体表示してくれる)
        window.open(url,'pop2','width=1600,height=1600,left='+left+',top=0,scrollbars=1');
}
</script>
<a href="javascript:void(0);" onClick="wopen('http://localhost:8000/b.html');">開く</a>
b.html
hi

方法2. 開いてから移動

a.html
<script>
function wopen(url){
        //現在使用しているモニターの横幅を取得
        var left = window.parent.screen.width;
        //開く
        window.open(url,'pop2','top=0');
}
</script>
<a href="javascript:void(0);" onClick="wopen('http://localhost:8000/b.html');">開く</a>
b.html
<script>
var left = window.parent.screen.width;
window.moveTo(left,0);
</script>
<body>
hi
</body>
1
2
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
1
2