【问题标题】:push url to other local page将 url 推送到其他本地页面
【发布时间】:2015-05-09 14:15:33
【问题描述】:

所以我为自己制作了一个 webos 应用程序。 我需要将 url/name 推送到另一个页面,然后重定向并查看推送的 url。

我需要用 JQuery 来完成。

这就是我所拥有的。

    <div class="twitch-widget-gamelist" id="twitch-widget-gamelist">
         // IN HERE IS A LOST OF GAMES
    </div>
    <div class="twitch-widget-streamlist" id="twitch-widget-streamlist">
         // IN HERE IS A LOST OF STREAMERS. THESE ARE LOADED WITH JQUERY/JSON SEE BELOW
    </div>

这是带有 JSON 加载的 JQuery

$(document).on("click", "#twitch-widget-gamelist a", function(e) {
          e.preventDefault();
          var id = $(this).attr("id");
          var name = $(this).attr("name");

          $("#game-list-header").text(name);

          name = name.replace(/\s/g,"+");
          name = name.replace(/\:/g,"%3A");

          $("#twitch-widget-gamelist").empty();

          $.ajax({
                url: 'https://api.twitch.tv/kraken/streams?game=' + name + '&limit=100',
                type: 'GET',
                contentType: 'application/json',
                dataType: 'jsonp',
                success: function(data) {

                    $.each(data.streams, function(index, value){

                        $("#twitch-widget-streamlist").append("<a href='#' name='" + value.channel.name + "' id='" + value._id + "'><img src='" + value.preview.medium + "'></a>");

                    })
                }
            });
        });

当点击这些图像/链接之一时,它应该重定向到stream.html 并显示流。在stream.html 中,我已经得到了这个:

<div class="right_panel_stream">
        <iframe id="player" type="text/html" width="100%" height="100%" src="https://www.nightdev.com/hosted/obschat/?style=light&channel=sodapoppin&fade=false&bot_activity=false" frameborder="0"></iframe>
    </div>

不知何故,我需要将流名称(value.channel.name)推送到stream.html,这样我就可以通过点击任何图像/链接来更改“sodapoppin”。

如何做到这一点?

【问题讨论】:

  • 重定向时可以通过location.hash传递参数。
  • 谢谢,这对我有帮助!

标签: jquery json post get


【解决方案1】:

正如@Ruslanas Balčiūnas 所说。我可以使用location.hash 来做到这一点。它起作用了,我能够将主题标签发送到另一个页面,并使用location.hash 来获取主题标签,以达到所需的目的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-13
    • 2011-02-09
    • 2022-01-09
    • 1970-01-01
    • 2014-01-18
    • 1970-01-01
    • 2019-07-29
    相关资源
    最近更新 更多