简体   繁体   English

需要一键打开新选项卡中的链接并关闭当前选项卡

[英]Need to open link in new tab and close current tab with one click

I find myself in need of a script to (1) open a link in a new tab and (2) close the current tab so the back button cannot be used to see the website that was previously being viewed. 我发现自己需要一个脚本来(1)在新选项卡中打开链接,以及(2)关闭当前选项卡,因此后退按钮不能用于查看以前正在查看的网站。 This is a security feature for a site, and unfortunately I'm at a complete loss. 这是网站的一项安全功能,很遗憾,我完全不知所措。 Nothing I've tried works and I don't know where to begin. 我没有尝试过任何工作,也不知道从哪里开始。 This is likely very simple and is staring me in the face, but I don't normally find myself needing to use java for anything. 这可能非常简单,并且正盯着我,但我通常不会发现自己需要使用Java做任何事情。 Any ideas? 有任何想法吗?

Its impossible, but as found in this thread how to stop browser back button using javascript you can prevent users from going back. 这是不可能的,但是如本线程所述, 如何使用javascript停止浏览器后退按钮可以防止用户后退。

Theres a JS bin with an example 有一个JS bin的例子

Edit - Please bear in mind the warning 'It is generally a bad idea overriding the default behavior of web browser.' 编辑-请记住警告“一般来说,重写Web浏览器的默认行为是一个坏主意。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM