Paul
Paul

Reputation: 1966

JavaScript: Iframe's width attribute change based on the available space?

How to, using JavaScript, resize an iframe, so its width will be equal to real value of available space?

Setting width to 100% results in white borders around the meant iframe.

Upvotes: 0

Views: 496

Answers (1)

alex
alex

Reputation: 490173

If you want your iframe to cover your entire site, and don't want to use a frameset page, try...

CSS

html,
body {
   height: 100%;  
}   

body {
   margin: 0;
   padding: 0;
     
}

iframe {
   width: 100%;
   height: 100%;   
   border: none;  
}

See it on jsFiddle.

Upvotes: 1

Related Questions