开发者

Change parameters in iframe src attribute with jQuery

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 :

开发者_如何学Go
<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 !


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?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜