window.open is not applying the given height parameter

…衆ロ難τιáo~ 提交于 2020-01-04 13:39:35

问题


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

my window.open syntax is as follows

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....


回答1:


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:-

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.




回答2:


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.




回答3:


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");
     }


来源:https://stackoverflow.com/questions/9612745/window-open-is-not-applying-the-given-height-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!