当我查看Firefox网络选项卡时,它看起来像是GET请求,但页面没有得到HTML响应。我正在使用jQuery添加一个列表项,其中包含徽标,名称和链接,如果单击徽标或名称,则需要指向用户。代码位于此处:http://codepen.io/veronikabenkeser/pen/PqxYvb
相关的JS代码:
if (logo === null) {
logo = '<img class = "brownI" src= "http://i358.photobucket.com/albums/oo27/picturesqueworlds/rss_circle_webtreatsetc_zpsfouqr1gj.png" >';
} else {
logo = '<img src="' + logo + '">';
}
if (stream !== null) {
streamingIcon = '<img class = "streamIcon" src= "http://i358.photobucket.com/albums/oo27/picturesqueworlds/button_green_play_zpsgnkih0jo.png" >';
item = '<li>' + '<a href="http://www.twitch.tv/' + streamer + '"' + '>' + logo + '</a>' + '<a href="http://www.twitch.tv/' + streamer + '"' + '>' + name + '</a>' + streamingIcon + '</li>';
} else {
item = '<li>' +
'<a href="http://www.twitch.tv/' + streamer + '"' + '>' + logo + '</a>' + '<a href="http://www.twitch.tv/' + streamer + '"' + '>' + name + '</a>' + '</li>';
}
$(".content ul").append(item);
答案 0 :(得分:1)
您可以使用委派的事件处理程序,因为附加了链接。
类似的东西:
$(".content").on('click','a',function(){
var theSource = $(this).attr('href');
window.open(theSource , '_blank');
});
答案 1 :(得分:0)
单击链接时链接不起作用的原因是因为内容与codepen.io位于不同的域并违反了UpdateData();
政策
拒绝在相框中显示“http://www.twitch.tv/freecodecamp” 因为它将'X-Frame-Options'设置为'SAMEORIGIN'。
一种解决方法是将m_edit_string
添加到您的href