I have the following link in my view that opens a changelog in a new page:
我在视图中有以下链接,在新页面中打开更改日志:
<%= link_to("Changelog", changelog_path, :target => "_blank") %>
In this changelog page I would like to create a link to close this changelog page.
在此更改日志页面中,我想创建一个关闭此更改日志页面的链接。
What is the most appropriate way to do this ?
最合适的方法是什么?
Is that possible to achieve this without Javascript ?
没有Javascript可以实现这一点吗?
1 个解决方案
#1
3
You will need to use JavaScript for this. You can call window.close()
, but this will prompt the user before closing the window, unless the window was opened from JavaScript with window.open()
, so you will also need to use JavaScript for opening the window instead of a link with target="_blank"
.
您需要使用JavaScript。您可以调用window.close(),但这会在关闭窗口之前提示用户,除非窗口是使用window.open()从JavaScript打开的,因此您还需要使用JavaScript打开窗口而不是链接目标=“_空白”。
#1
3
You will need to use JavaScript for this. You can call window.close()
, but this will prompt the user before closing the window, unless the window was opened from JavaScript with window.open()
, so you will also need to use JavaScript for opening the window instead of a link with target="_blank"
.
您需要使用JavaScript。您可以调用window.close(),但这会在关闭窗口之前提示用户,除非窗口是使用window.open()从JavaScript打开的,因此您还需要使用JavaScript打开窗口而不是链接目标=“_空白”。