Javascript:如何在点击播放后重定向到另一个页面.png


Javascript: How to redirect to another page after click play.png?

我刚买了电影剧本,我想调整一些东西,但我不知道该怎么做。所以,我希望你能帮助我。

使用此代码,当有人单击"播放.png"时,将播放预告片。但是,我想在他们单击播放.png时重定向到另一个页面。怎么办呢?

这是 html:

                    <div id="trailer-mask" data-bind="click: showTrailer" data-src="{{ $title->trailer }}">
                        <img class="img-responsive img-thumbnail" src="{{ $title->background }}">
                        <div class="center"><img class="img-responsive" src="{{ asset('assets/images/play.png') }}"> </div>
                    </div>

这是javascript:

showTrailer: function() {
    var e = s("#trailer-mask");
    "default" == vars.trailersPlayer ? e.html('<div class="embed-responsive embed-responsive-16by9"><iframe class="embed-responsive-item" src="' + e.data("src") + '?autoplay=1&iv_load_policy=3&modestbranding=1&rel=0" wmode="opaque" allowfullscreen="true"></iframe></div>') : (-1 != e.data("src").indexOf("youtube") ? videojs("trailer", {
        techOrder: ["youtube"]
    }).src(e.data("src")).play() : videojs("trailer", {
        techOrder: ["html5", "flash"]
    }).src(e.data("src")).play(), e.css("display", "none"), s("#trailer").css("display", "block"), s("#social").css("top", 0).css("left", 0), s("#lists").css("top", 0).css("right", 0), videojs("trailer").on("userinactive", function() {
        s("#social").css("display", "none"), s("#lists").css("display", "none")
    }), videojs("trailer").on("useractive", function() {
        s("#social").css("display", "block"), s("#lists").css("display", "block")
    }))
},

使用上面的代码,如果

试试这个

$(".img-responsive").click(function(){
   window.location.href = "http://your-website.com";
});

只需在单击该图像(其中包含一个名为 .img-responsive 的类)时触发重定向:

$(".img-responsive").click(function(){
   window.location = "http://www.go-to-link.com";
});

Javascript Way:

location.href="http://www.domain.com/";

在新标签页中打开:

window.location("http://www.domain.com/");

jQuery方式:

$(location).attr('href','http://www.domain.com/');

你可以在 js 函数中执行此操作:

showTrailer: function() {
    window.location.href = "http://yourDESIREDurl.com";
},

如果你有一个动态生成的div,那么在jQuery中你可以这样使用事件委托:

$(document).on('click', '.img-responsive', function(){
    window.location.href = "http://yourDESIREDurl.com";
});