gpt4 book ai didi

javascript - 如何将弹出窗口放置在屏幕的右上角

转载 作者:行者123 更新时间:2023-12-03 01:30:38 25 4
gpt4 key购买 nike

我想要做的是更改窗口的大小并在其旁边创建一个窗口,以便它们彼此完全相邻。从这个意义上说,我需要将新窗口定位到屏幕的右上角,我这样做的方式不起作用(代码如下),我需要帮助:)

function () { 
var viewportwidth = document.documentElement.clientWidth;
var viewportheight = document.documentElement.clientHeight;
window.resizeBy(-300,0);
window.open("something.htm",
"mywindow",
"width=300,
height=viewportheight,
left=(viewportwidth - 300),
top=0,
screenX=0,
screenY=0");
}

最佳答案

var viewportwidth = document.documentElement.clientWidth;
var viewportheight = document.documentElement.clientHeight;
window.resizeBy(-300,0);
window.moveTo(0,0);

window.open("http://google.com",
"mywindow",
"width=300,left="+(viewportwidth-300)+",top=0");

关于javascript - 如何将弹出窗口放置在屏幕的右上角,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3161547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com