Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change height of iframe when it loads?

$('#song-link').change(function () {
  var link = $('#song-link').val();
  SC.oEmbed(link, {
    element: document.getElementById('putTheWidgetHere')
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://connect.soundcloud.com/sdk/sdk-3.1.2.js"></script>
<input  id="song-link" placeholder="Paste Soundcloud link here" name="song_link"   type="text">
<div id="putTheWidgetHere"></div>

Code helps me to preview the link of soundcloud. You can test its works fine. but i want to change its height from 400px to 200px. I have tried adding addclass() and css(). But it didn't work.

I couldn't figure which event will trigger these functions since the height must be set after the link is pasted on input text and loads on the iframe that soundcloud loads.

like image 265
Saugat Thapa Avatar asked Jul 12 '16 06:07

Saugat Thapa


1 Answers

Try this:

#putTheWidgetHere iframe {
    min-height: 200px;
    height: auto;
}
like image 194
Pranjal Avatar answered Nov 14 '22 06:11

Pranjal