0
所以即时为我自己制作一个webos应用程序。 我需要将网址/名称推送到其他页面,然后重定向并查看推送的网址。推送网址到其他本地页面
我需要用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>
这是JQuery的使用JSON负载
$(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.htm
升我有了这个迄今:
<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'传递参数。 –
谢谢,这帮了我! –