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
- Adjust width height of iframe to fit with content in it
- Resizing an iframe based on content
- iframe dynamic height width change based on inner content
- How to auto-size an iFrame?
精彩评论