duanliaolan6178
2013-08-19 13:36
浏览 38
已采纳

特定值的隐藏iframe?

I want to hide iframe if there is no $content present.

<div class="video">
    <iframe width="600px" height="400px" src="'.$content.'?autoplay=1" frameborder="0" scrolling="no" allowfullscreen style="visibility:hidden;" onload="this.style.visibility=\'visible\';"></iframe>
</div>

In my case if $content is not present, iframe loads src="?autoplay=1"

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • du155305 2013-08-19 13:57
    已采纳

    I think this will do the trick:

    <?php
        // Test if variable is set and has content in it
        if( isset($content) && $content != "") {
            echo '<div class="video"><iframe width="600px" height="400px" src="'.$content.'?autoplay=1" frameborder="0" scrolling="no" allowfullscreen style="visibility:hidden;" onload="this.style.visibility=\'visible\';"></iframe></div>'
        }
    ?>
    

    This way the iframe will not be printed in the html in case of no content.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题