使用以下内容,我允许用户右键单击链接以在新选项卡/窗口中打开。我希望链接将颜色更改为紫色以显示它已被访问。问题是当用户刷新页面时,我无法让链接颜色保留紫色属性。还有一个问题是保持“a.advanced”等链接不改变颜色。
//Sets anchor link color to purple when right clicked and opened as new tab/window.
$(document).on("mousedown", "a",
function (e) {
if (e.button == 2) {
$(this).css("color", "purple");
return false;
}
return true;
});
//sets color of visited anchor links to purple.
$('a:visited').css("color", "#416b99");
//Keeps navigation items white when user right clicks to open in a new tab/window.
$(document).on("mousedown", "a.nav-item, a.advanced, a.user-support, a.user-myknovel, a.user-welcome",
function (e) {
if (e.button == 2) {
$(this).css("color", "white");
return false;
}
return true;
});