【问题标题】:Append src in iframe在 iframe 中附加 src
【发布时间】:2017-06-13 01:46:24
【问题描述】:

我在我的网站上通过动态创建的 iframe 加载了 vimeo 视频。对于移动设备,我需要从以下位置更改 src:

<iframe src="https://player.vimeo.com/video/220535146?controls=0&hd=1&autoplay=1&player_id=banneroneVid&api=1" width="640" height="360" frameborder="0" title="reebok_short_loop" webkitallowfullscreen mozallowfullscreen allowfullscreen frameborder="0" id="banneroneVid" ></iframe>

<iframe src="https://player.vimeo.com/video/220535146?background=1" width="640" height="360" frameborder="0" title="reebok_short_loop" webkitallowfullscreen mozallowfullscreen allowfullscreen frameborder="0" id="banneroneVid" ></iframe>

理想情况下,我希望在页面加载时发生这种情况。

谢谢

【问题讨论】:

    标签: iframe append vimeo src


    【解决方案1】:

    根据设备使用媒体查询加载所需的 iframe。

    类似这样的:(例如,如果您使用引导程序)

    <!-- bigger screens -->
    <div class="hidden-xs col-sm-12 col-md-12 col-lg-12">
        <iframe src="https://player.vimeo.com/video/220535146?controls=0&hd=1&autoplay=1&player_id=banneroneVid&api=1" width="640" height="360" frameborder="0" title="reebok_short_loop" webkitallowfullscreen mozallowfullscreen allowfullscreen frameborder="0" id="banneroneVid" ></iframe>
    </div>
    
    <!-- mobile devices with max-width: 768px -->
    <div class="col-xs-12 hidden-sm hidden-md hidden-lg">
        <iframe src="https://player.vimeo.com/video/220535146?background=1" width="640" height="360" frameborder="0" title="reebok_short_loop" webkitallowfullscreen mozallowfullscreen allowfullscreen frameborder="0" id="banneroneVid" ></iframe>
    </div>
    

    【讨论】:

    • 这是个好主意,但在这种情况下,URL 是在网站加载时生成的,所以我认为我需要阅读 URL,然后通过 php 或 jquery 更改它
    猜你喜欢
    • 1970-01-01
    • 2013-01-26
    • 2023-03-28
    • 2021-08-28
    • 1970-01-01
    • 1970-01-01
    • 2012-03-06
    • 1970-01-01
    • 2019-01-07
    相关资源
    最近更新 更多