Create new tab and rename its title

Create new tab and rename its title

In my single page application a user can open links in a NEW tab. I would like the tab's title be named based on the particular link they clicked. However, the original tab's title gets renamed.

Can someone show me how to rename my "New" tab instead?

  1. $("#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.
            newWindow.document.title = level_three_page_name;

            event.preventDefault();

            window.focus();
        }
    });