javascript window.open 没有应用给定的高度参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9612745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
window.open is not applying the given height parameter
提问by OM The Eternity
I have a onclick event on a link inwhich window.open for a url is executed , I have also given the custom width and height for it, but is not accepting it and pop window is displayed with different width and height.. can someone guide me what must be wrong with that
我在执行 url 的 window.open 的链接上有一个 onclick 事件,我还为它提供了自定义宽度和高度,但没有接受它,并且弹出窗口以不同的宽度和高度显示..有人可以指导我一定有什么问题
my window.open syntax is as follows
我的 window.open 语法如下
onclick='var myW=window.open ("http://www.google.co.jp/","mywindow","location=1,toolbar=1,menubar=1,resizable=1,width=846,height=786");
Also how to change the display position of pop window in the screen?
还有如何改变弹窗在屏幕中的显示位置?
NOTE: AFTER ALL THE REPLIES Being Positive with my code.. I tried it and found after thinking about it that whatever size I was giving in parameter the browser taking it more than that... May be thats due to resolution....
注意:在所有回复都对我的代码持肯定态度之后..我尝试了它,并在考虑之后发现无论我在参数中给出的大小如何,浏览器都会超过它......可能是由于分辨率......
采纳答案by Pranav
your code is working fine :
你的代码工作正常:
<html>
<head>
</head>
<body>
<input type="button" value="cl" onclick='var myW=window.open
("http://www.google.co.jp/","mywindow","location=1,toolbar=1,menubar=1,resizable=1,width=200,height=200");'>
</body>
</html>
for more check this:- http://www.w3schools.com/jsref/met_win_open.asp
to window position a pop up window just after it opens use:-
有关更多信息,请检查:- http://www.w3schools.com/jsref/met_win_open.asp
在打开后立即定位弹出窗口:-
window.moveTo(50,50);//your window object:-
The parameters for the moveTo are the left position followed by the top position for the top left corner of the window.
moveTo 的参数是窗口左上角的左侧位置和顶部位置。
回答by Misha Ts
function mypopup()
{
mywindow = window.open("http://www.javascript-coder.com", "mywindow", "location=1,status=1,scrollbars=1, width=100,height=100");
mywindow.moveTo(0, 0);
}
The code positions the popup on the top left corner of the screen with width and height 100px.
该代码将弹出窗口放置在屏幕的左上角,宽度和高度为 100 像素。
回答by Vinod
Try this:
试试这个:
function popup_win()
{
var mywdw = window.open("http://www.google.com/", "mywindow", "location=1,toolbar=1,menubar=1,resizable=1,width=100,height=100,top=250, left=350");
}