I am going to host my app in a site. The app will be shown inside an iframe in it. i need my app to be on full screen, is there anyway where I can change the size of that iframe which will hold my app from my application?? My app and the site hosting it are not the same domain.
$("iframe", window.parent.document).css("width", "1000px");
this is not working as the site and app do not belong to same domain
To get the iframe to properly use 100% the parent needs to be 100%. In newer doctypes the html and body tag are not automatically 100%. When I added height:100% for html and body then it worked flawlessly.
position: absolute; This will give the iframe a position relative to the wrapper and let it be positioned over the padding of the wrapper. top: 0 and left: 0 are used to position the iframe at the center of the container. width: 100% and height: 100% make the iframe take all of the wrapper's space.
The sanest way, if your app needs to run full screen, is to break out of the iframe. That is, detect if your page is in an iframe, and if so, redirect the browser to your page so that is is no longer in the iframe!
This page explains how to do it:
<script type="text/javascript">
if (top.location!= self.location) {
top.location = self.location.href;
}
</script>
If you control both pages then you can use HTML5 Post message:
outside:
$(window).bind("message", function(e) {
$('iframe').attr({
width: e.originalEvent.data.width,
height: e.originalEvent.data.height
});
});
inside:
$('button').click(function() {
parent.postMessage({width: '200px', height: '200px'}, 'http://localhost');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With