Javascript 如何打开屏幕右下角的弹出窗口
我点击了一个按钮,使用javascript window.open打开一个弹出窗口 我的代码如下所示:Javascript 如何打开屏幕右下角的弹出窗口,javascript,window.open,Javascript,Window.open,我点击了一个按钮,使用javascript window.open打开一个弹出窗口 我的代码如下所示: <button onclick="myFunction()">Try it</button> <script> function myFunction() { window.open('', '', 'height=5,width=5'); } </script> <script> function myFunction() {
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
window.open('', '', 'height=5,width=5');
}
</script>
<script>
function myFunction() {
height=5;
width=5;
t=window.innerHeight-height
l=window.innerWidth-width
window.open('', '', 'height='+height+', width='+width+', left='+l+', top='+t );
现在,弹出窗口在屏幕的左上角打开。
如何设置弹出窗口,使其在右下角打开,以便用户不知道弹出窗口是否打开
提前感谢window.openurl、name、specs、replace是正确的,但您将高度和宽度作为specs参数传递。尝试将其替换为顶部和左侧 window.openurl、名称、规格、替换是正确的,但您将高度和宽度作为规格参数传递。尝试将其替换为顶部和左侧 如果您指的是窗口大小-弹出窗口大小,则如下所示:
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
window.open('', '', 'height=5,width=5');
}
</script>
<script>
function myFunction() {
height=5;
width=5;
t=window.innerHeight-height
l=window.innerWidth-width
window.open('', '', 'height='+height+', width='+width+', left='+l+', top='+t );
}
其中:
-t=底部-弹出高度
-l=右-弹出窗口宽度
请注意,此示例适用于Chrome/Firefox/。。。
IE使用不同的sintax检索窗口大小值如果您指的是窗口大小-弹出窗口大小,则如下所示:
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
window.open('', '', 'height=5,width=5');
}
</script>
<script>
function myFunction() {
height=5;
width=5;
t=window.innerHeight-height
l=window.innerWidth-width
window.open('', '', 'height='+height+', width='+width+', left='+l+', top='+t );
<p>Click the button to open a new window.</p>
<button onclick="openWindow()">Open</button>
<script>
var topsss=screen.height-490;
var left=screen.width-420;
function openWindow() {
window.open("https://www.google.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top="+topsss+",left="+left+",width=420,height=490");
}
</script>
}
其中:
-t=底部-弹出高度
-l=右-弹出窗口宽度
请注意,此示例适用于Chrome/Firefox/。。。
IE使用不同的sintax来检索窗口大小值What@polkovnikov.ph所说的内容,但如果您已经下定决心,这里有相关信息。是的,尝试了同样的方法。但是无法确定屏幕右下角的位置@polkovnikov.ph说了什么,但是如果你死心塌地,这里有相关信息。是的,尝试了相同的。但是无法确定我屏幕右下角的位置尝试了这个..它仍然在屏幕中央打开。你在使用哪个浏览器?刚刚测试过它在Chome中运行良好,并尝试了这个。它仍然在屏幕中央打开。你使用的是哪种浏览器?刚刚测试它在Chome和FFE中工作正常,这将被弹出窗口阻止程序阻止。这将被弹出窗口阻止程序阻止。
<p>Click the button to open a new window.</p>
<button onclick="openWindow()">Open</button>
<script>
var topsss=screen.height-490;
var left=screen.width-420;
function openWindow() {
window.open("https://www.google.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top="+topsss+",left="+left+",width=420,height=490");
}
</script>