javascript - Can it be determined if window.resizeTo will work? -



javascript - Can it be determined if window.resizeTo will work? -

inside javascript console, if execute:

m = window.open(location.origin); m.resizeto(400, 400);

the window resize, if execute:

window.resizeto(400, 400);

then nil happens. understand reason behavior. how can observe situations window.resizeto nothing?

approach 1:

you can utilize window.opener property. if it's null, did not open window , cannot resize it.

window.parent intended more iframes , like.

such as:

if (m.opener) { m.resizeto(400, 400); } else { // did not create window, , not able resize it. } approach 2:

ajp15243 brings point, 1 thing hear resize event , see if resizeto worked:

var resizefired = false; ... var triggeredresize = function() { resizefired = true; m.removeeventlistener('resize', triggeredresize); } m.addeventlistener('resize', triggeredresize, true); m.resizeto(400, 400); if (resizefired) { // resize worked. }

i haven't been able test this, it's 1 potential approach nonetheless. ie8 , below may need utilize attachevent instead. @wesabi noted, resize may fire other events (and may fire if user resizing window listener attached), it's best execute shortest time span possible.

approach 3:

another approach phone call m.resizeto(400, 400) , check window size see if current size equal set to:

m.resizeto(400, 400); if (w.outerwidth != 400 && w.outerheight != 400) { // resize didn't work }

javascript

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -