window.addEventListener("message", receiveMessage, false); function receiveMessage(event) { // Do we trust the sender of this message? (might be // different from what we originally opened, for example). $("body").append(""); $("#bxr-iframe").width(event.data); $("#bxr-iframe").height(window.innerHeight); $("#bxr-iframe").css({ 'width': event.data+'px', 'height': window.innerHeight+'px', }); $("body").append("
resized"+$("#bxr-iframe").width()+"
"); } $(window).on('orientationchange',fixFrame); $(window).resize(fixFrame); function fixFrame(event) { parent.postMessage('Hi Vso','*'); }