【发布时间】: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传递参数。 -
谢谢,这对我有帮助!