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'傳遞參數。 –
謝謝,這幫了我! –