【问题标题】:how to change height of iframe when it loads?加载时如何更改iframe的高度?
【发布时间】:2016-11-14 05:59:51
【问题描述】:

$('#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>

代码帮助我预览 soundcloud 的链接。你可以测试它的工作正常。但我想将其高度从400px 更改为200px。我尝试添加addclass()css()。但它没有用。

我无法确定哪个事件会触发这些函数,因为必须在将链接粘贴到输入文本并加载到 soundcloud 加载的iframe 上之后设置高度。

【问题讨论】:

    标签: jquery html css iframe


    【解决方案1】:

    试试这个:

    #putTheWidgetHere iframe {
        min-height: 200px;
        height: auto;
    }
    

    【讨论】:

    • 您应该将“我要求 200px”添加到 cmets,而不是将其编辑为答案 @Saugat Thapa
    • 哦哈哈对不起...我会的。我的编辑选项现在被禁用了
    猜你喜欢
    • 1970-01-01
    • 2020-12-11
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-02
    • 1970-01-01
    • 2015-05-17
    相关资源
    最近更新 更多