0
votes

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 !

1
What's the problem with the code in your question?Matt Ball
this code does not affects the width of the iframe. still 710pxJulien CHAZAL
check the contentwidth and contentheight are getting right valueAmila
thx amilia this are getting right values because i use them to adapt width of facebook like box ;-)Julien CHAZAL

1 Answers