简体   繁体   中英

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

I have opened a poup 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM