Does anyone know of a way to auto resize an iframe when you make your browser smaller??
Asked
Active
Viewed 3,360 times
0
-
possible duplicate of [How to resize iframe when parent window resizes](http://stackoverflow.com/questions/6634582/how-to-resize-iframe-when-parent-window-resizes) – MK. Feb 24 '12 at 14:07
-
check this it is the best preview sample http://stackoverflow.com/questions/10845452/how-to-render-a-full-webpage-in-smaller-iframe – Joseph Aguilar Aug 06 '13 at 09:53
5 Answers
1
You can attach a handler to the window.onresize
event, and then resize your IFRAME appropriately.
I prefer jQuery:
$(window).resize(function() {
$('IFRAME').width($(window).width());
});

moribvndvs
- 42,191
- 11
- 135
- 149
0
Haven't tried it but I guess you could use a percentage width instead of a fixed width. In that case you should probably add a minimum width and height as well, to avoid that it is getting too small:
iframe
{
width: 50%;
height: 50%;
min-width: 300px;
min-height: 300px;
}

Christofer Eliasson
- 32,939
- 7
- 74
- 103
0
You can also do this without JavaScript if you'd like using CSS Media Queries. See this example here:
http://ie.microsoft.com/testdrive/HTML5/CSS3MediaQueries/Default.html
They are often used for "responsive design".

pseudosavant
- 7,056
- 2
- 36
- 41