0

Searched a lot but didn't find exactly what i'm looking for. I want to resize an iframe dynamically with width of his container.

HTML :

<div class="row hidden" id="audio">
            <div class="twelvecol last">
            <iframe id="deezer" scrolling="no" frameborder="0" allowTransparency="true" src="http://www.deezer.com/fr/plugins/player?autoplay=false&playlist=true&width=710&height=308&scover=true&type=album&id=42808&title=" width="710" height="308"></iframe>
            </div>
        </div>

Thx to jQuery i try to inject width and height of div#content into parameters of the iframe's src attribute :

<script>
$(document).ready(function(){
        var contentwidth = $('#content').width();
        var contentheight = $('#content').height(); 
        var iframeUrl = 'http://www.deezer.com/fr/plugins/player?autoplay=false&playlist=true&width=' + contentwidth + '&height=' + contentheight + '&scover=true&type=album&id=42808&title=';
        $('#deezer').attr('src', iframeUrl).attr('width', contentwidth).attr('height', contentheight);   
});
</script> 

Thx for your help !

Julien CHAZAL
  • 231
  • 5
  • 15

1 Answers1

0

Here is solutions

  1. Adjust width height of iframe to fit with content in it
  2. Resizing an iframe based on content
  3. iframe dynamic height width change based on inner content
  4. How to auto-size an iFrame?
Community
  • 1
  • 1
kst
  • 1,438
  • 3
  • 19
  • 33