简体   繁体   English

希望在按下按钮时使用 JavaScript 关闭 safari 选项卡

[英]Looking to close a safari tab on button press with JavaScript

I can close tabs/window on every browser except for Safari so far... Any idea what to do to close a Safari tab?到目前为止,我可以关闭除 Safari 之外的每个浏览器上的选项卡/窗口......知道如何关闭 Safari 选项卡吗?

This is what I'm working with:这就是我正在使用的:

jQuery(function ($) {
    $( document ).ready(function() {
        $(".et_pb_slide_0.et_pb_slide .et_pb_more_button.et_pb_button").on("click", function(){
            window.open('','_self').close();
        });
    }); 
});

Actually the close() method also works in safari.实际上close()方法也适用于 safari。 W3School close() See the browser supported by the close() W3School的close()见支持的浏览器close()

 window.close();

Hope this help.希望这有帮助。

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

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