【问题标题】:set external link to youtube iframe video设置指向 youtube iframe 视频的外部链接
【发布时间】:2012-11-21 04:38:34
【问题描述】:

我在我的网站中使用 iframe youtube 视频。

示例代码:

<iframe width="414" height="270" src="samplecode" frameborder="0" allowfullscreen></iframe>

如果我点击 youtube 视频,它将重定向到外部页面。我使用了下面的代码。

<a href="#"> <iframe width="414" height="270" src="samplecode" frameborder="0" allowfullscreen></iframe></a> 

我知道我的方法是错误的。它不工作。请确认无论如何都要这样做?

【问题讨论】:

    标签: html css video youtube


    【解决方案1】:

    这行不通。要解决您的问题,您必须使用 javascript。作为参考,您可以检查以下线程 Detect Click into Iframe using JavaScript

    另一种解决方案是

    <div style="position:relative">
    <div style="position:absolute;width:414px;height:270px" onclick='window.location.href="http://google.com"' ></div>
    <iframe width="414" height="270" src="samplecode" frameborder="0" allowfullscreen></iframe>
    </div>
    

    这里我叠加了另一个 div overiframe(我们不会为它设置任何背景,所以会看到 iframe 内容),它将具有 onclick 功能,可以将用户带到所需的 url

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-04
      • 2015-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-29
      相关资源
      最近更新 更多