更多操作
小无编辑摘要 |
小 (导入35个版本) |
||
(未显示同一用户的28个中间版本) | |||
第1行: | 第1行: | ||
// https://stackoverflow.com/questions/14346414/how-do-you-do-html-encode-using-javascript |
|||
function htmlEncode(value){ |
|||
//create a in-memory div, set it's inner text(which jQuery automatically encodes) |
|||
//then grab the encoded contents back out. The div never exists on the page. |
|||
return $('<div/>').text(value).html(); |
|||
} |
|||
$(".WikiaArticle a[title]").hover(function() { |
|||
if (this.className != "") { return; } // 作为 wikilink 的超链接没有 class |
|||
var a = $(this); |
|||
var title = a.attr("title"); |
|||
if (title != a.text()) { |
|||
a.append($('<span class="wikilink-popup">' + htmlEncode(title) + '</span>')); |
|||
} |
|||
}, function() { |
|||
$(this).find(".wikilink-popup").remove(); |
|||
}); |