我使用以下命令打开带有一些页面内容的新标签页(在新进程中),
var p = document.getElementById("myElement");
var a = document.createElement('a');
a.setAttribute('href',".../mypage.html");
a.setAttribute('rel',"noreferrer");
a.setAttribute('target',"_blank");
p.appendChild(a);
a.click();
http://news.softpedia.com/news/Force-Google-Chrome-to-Open-Links-in-New-Processes-128962.shtml
当您使用此代码时,它总是会打开新标签页, 我希望当您调用此代码时,它会查看它是否是在新选项卡中打开的先前调用,然后它将关闭它并且新调用将在新选项卡中打开。 或者可能在不关闭上一个选项卡的情况下运行新页面。
我不能使用常规的 window.open API ...
最佳答案
关于javascript - 如何在不使用打开窗口的情况下关闭选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40193727/