【问题标题】:Javascript: How to redirect to another page after click play.png?Javascript:单击play.png后如何重定向到另一个页面?
【发布时间】:2014-12-24 07:02:58
【问题描述】:

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

使用此代码,当有人单击“play.png”时,将播放预告片。但是,当他们单击 play.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")
    }))
},

有了上面的代码,如果

【问题讨论】:

    标签: javascript php jquery html redirect


    【解决方案1】:

    试试这个

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        【解决方案3】:

        Javascript 方式:

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

        在新标签页中打开:

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

        jQuery 方式:

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

        【讨论】:

          【解决方案4】:

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

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

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

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

          【讨论】:

            猜你喜欢
            • 2021-09-07
            • 2014-11-21
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2020-12-20
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多