所以我为自己制作一个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.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
”,点击图片/链接。
如何做到这一点?
答案 0 :(得分:0)
正如@RuslanasBalčiūnas所说。我可以使用"{:?}"
来执行此操作。它工作正常,我能够将标签发送到另一个页面,并使用location.hash
获取标签,以达到所需的目的。