在我的网站上,我有许多用户可以单击的链接。我有javascript(contextMenu),它允许用户在新选项卡中打开任何链接。当他们选择在新标签中打开链接时,我想根据他们单击的内容来重命名新标签。但是,原始选项卡被重命名。有人可以告诉我我哪里出问题了,以及如何重命名我的“新建”标签?
$("#contextMenu").contextmenu({
delegate: ".hasmenu",
menu: [
{ title: "Open in new tab" },
],
select: function (event, ui) {
var page = ui.target.children('a').context.nameProp;
var parent = $(this).closest('div').attr('id');
var parentId = ui.target.context.parentNode.parentNode.id;
var level_three_page_name = page.substring(0, page.indexOf(".htm"));
var url = window.location.protocol + "//" + window.location.host + window.location.pathname + "#/search/" + parentId + "/" + level_three_page_name;
var newWindow = window.open(url, '_blank');
// The rename works correctly but the original tab gets named.
window.document.title = level_three_page_name;
event.preventDefault();
window.focus();
}
});