isk*_*lue 1 javascript window.open
我的目标是将使用该window.open()方法打开的新窗口定位在屏幕的右下角,但是设置right=0并bottom=0不起作用。
更改width和height会有所不同,但更改、 或top仍然bottom会导致窗口在左上角打开。rightleft
这是为什么?如何将窗口放置在右下角?
window.open('https://google.com', '_blank', 'location=yes, height=250,width=550, right=0, bottom=0, scrollbars=yes,status=yes');
Run Code Online (Sandbox Code Playgroud)
您需要将顶部和左侧设置为内部高度和宽度减去新窗口的高度和宽度。
<script>
function OpenMe(){
var height = 250;
var width = 550;
var top = window.innerHeight-height;
var left = window.innerWidth-width;
window.open(
'https://google.com',
'_blank',
'location=yes,height='+height+',width='+width+',top='+top+',left='+left+',scrollbars=yes,status=yes'
);
}
</script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6757 次 |
| 最近记录: |