【问题标题】:jQuery popup for YouTube iframe not working in FirefoxYouTube iframe 的 jQuery 弹出窗口在 Firefox 中不起作用
【发布时间】:2014-01-22 19:59:01
【问题描述】:

我的以下代码在 Chrome 和 IE 中运行良好,但在 Firefox 中结果是不可接受的,因为它使视频占据了整个窗口。任何想法和想法都会受到赞赏。

$("a.link").click(function() {
    var a_href = $(this).attr('href');
    //console.log(a_href);
    $('#vidholder').prop('src', a_href);
    $('#vidholder').prop('height', 300);
    $('#vidholder').prop('width', 400);

    if ($("#vid-wrapper").is(":hidden")) {
        $("#vid-wrapper").slideDown("fast");
    } else {
        $("#vid-wrapper").hide();
    }
    event.preventDefault();
});

【问题讨论】:

  • 你能否对整个 html 进行 pst 以查看 jquery 如何链接到 JQuery 的部分。

标签: javascript jquery iframe youtube


【解决方案1】:

你忘了定义event

$("a.link").click(function(event) {

【讨论】:

    【解决方案2】:

    不知道它是否与问题有关,但请记住 $.prop() 用于布尔属性(例如“checked”属性)。对于像 width 和 src 这样的值属性,你应该使用 $.attr() 所以你的代码应该是这样的:

    $('#vidholder').attr('src', a_href);
    $('#vidholder').attr('height', 300);
    $('#vidholder').attr('width', 400);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 2020-12-06
      • 1970-01-01
      相关资源
      最近更新 更多