如何将弹出窗口放置在屏幕的右上角
我想要做的是更改窗口的大小并在其旁边创建一个窗口,以便它们彼此完全相邻。从这个意义上说,我需要将新窗口定位到屏幕的右上角,我这样做的方式不起作用(代码如下),我需要帮助:)
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");
}
What I want to do is to change the size of a window and create a window next to it so they are exactly next to each other. In that sense, I need to position to the new window to the top right part of the screen, the way I am doing it is not working (code is below), I need help :)
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");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还没有测试过实际的窗口大小数学;不确定这是否正确。但您遇到的第一个明显的问题是将变量嵌入到对 window.open 的调用中。尝试更改
为
基本上,如果您希望变量或数学得到解析,它们必须位于字符串之外。
I haven't tested out the actual window size math; not sure if that's correct. But the first, obvious, problem you have is embedding the variables into the call to window.open. Try changing
to
Basically, if you want the variables or the math to get resolved, they have to be outside the string.