简体   繁体   中英

Assign element width to window width after window rendered

I want to get an html element's width like so:

var elementWidth = document.getElementById("myElement").style.width;

Then I want to assign this to the current window which is a popup created using:

window.open("myUrl","myName","width=200,height=200");

How would I go about doing that? Any pointers coz the windows cant be assign width & height values like elements.

This can be done by doing:

var elemWidth = document.getElementById("myElem").style.width;
var elemHeight = document.getElementById("myElem").style.height;
window.resizeTo(elemWidth,elemHeight);

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