开发者

How to resize popup window from the main page after opening it?

I have opened a po开发者_如何学Cup up window with a specific width,height ,top,left.

var newwindow=window.open("one.html",'name','height=200,width=650,top=300,left=100');

After 5 seconds i need to change the width,height,top,left of the popup window from a setInterval function in the main page. how can i do that.?


This code must be in child window

function calledOnBodyLoad(){
  setTimeout(resize_now, 6000);
}

function resize_now(){
    window.moveTo(new_posx,new_posxy);
    window.resizeTo(newSizeX, newSizeY);
}

If you want to control the pop up window from the parent window then use the following (in parent window)

////
var newwindow=window.open("one.html",'name','height=200,width=650,top=300,left=100');
setTimeout(resize_now, 6000);
///


 function resize_now(){
        newwindow.moveTo(new_posx,new_posxy);
        newwindow.resizeTo(newSizeX, newSizeY);
    }

Remember in this case newwindow must be a global variable or pass it as a arguement to the resize_now function.

Demo here


Inside the OnLoad function of one.html, add a timer function that will get executed after five seconds. Make the necessary changes in that function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜