admin管理员组文章数量:1287489
My objective is to position a new window opened with the window.open()
method in the bottom righthand corner of the screen, but setting right=0
and bottom=0
does not work.
Changing width
and height
makes a difference, but changing top
, bottom
, right
or left
still results in the window opening in the top lefthand corner.
Why is this and how would one position the window in the lower right hand corner?
window.open('', '_blank', 'location=yes, height=250,width=550, right=0, bottom=0, scrollbars=yes,status=yes');
My objective is to position a new window opened with the window.open()
method in the bottom righthand corner of the screen, but setting right=0
and bottom=0
does not work.
Changing width
and height
makes a difference, but changing top
, bottom
, right
or left
still results in the window opening in the top lefthand corner.
Why is this and how would one position the window in the lower right hand corner?
window.open('https://google.', '_blank', 'location=yes, height=250,width=550, right=0, bottom=0, scrollbars=yes,status=yes');
Share
Improve this question
edited Sep 8, 2017 at 16:29
iskandarblue
asked Sep 8, 2017 at 16:21
iskandarblueiskandarblue
7,52617 gold badges70 silver badges146 bronze badges
2
- Have you been able to test my answer? Did you solve the problem you are having? – Aaron K. Commented Sep 10, 2017 at 1:37
-
Not the solution but no spaces allowed in the
windowFeatures
parameter. – MarcGuay Commented Nov 20, 2020 at 22:46
2 Answers
Reset to default 7You need to set the top and left to the inner height and width minus the height and width of your new window.
<script>
function OpenMe(){
var height = 250;
var width = 550;
var top = window.innerHeight-height;
var left = window.innerWidth-width;
window.open(
'https://google.',
'_blank',
'location=yes,height='+height+',width='+width+',top='+top+',left='+left+',scrollbars=yes,status=yes'
);
}
</script>
If opened from a browser window on the main monitor, positioning works just fine. If opened from a browser window on a different monitor then positioning fails. I tested this in Chrome.
本文标签: javascriptCannot position windows with windowopen()Stack Overflow
版权声明:本文标题:javascript - Cannot position windows with window.open() - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741310336a2371616.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论