如何使用jquery关闭浏览器中的当前选项卡 [英] How do close current tab in browser using jquery

查看:709
本文介绍了如何使用jquery关闭浏览器中的当前选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>我在mvc4 web应用程序中工作我们正在使用c#,jquery我的任务是关闭按钮上的当前选项卡单击我尝试了一些jquery代码它在IE中运行良好但它不是为Firefox和Chrome工作可以帮助我如何使用jquery关闭当前标签?

>Hi, i'm working in mvc4 web application we are using c#,jquery my task is to close the current tab on a button click i have tried with some jquery code it works well in IE but it does't work for Firefox and Chrome can any one help me how to close current tab using jquery?

    $('#submitCase').click(function () {                                                                                     
                $('#Messagesub').html("You are Closing Window");
                $("#Dialog").dialog({                    
                    modal: true,
                    resizable: false,
                    buttons: {
                        "Ok": function () {
                            CloseWithWindowOpenTrick();                           
                        }
                    }
                });
            });

function CloseWithWindowOpenTrick() {
        var objWindow = window.open(location.href, "_self");
        objWindow.close();
    }

推荐答案

' #submitCase')。click( function (){
('#submitCase').click(function () {


#Messagesub')。html( 您正在关闭窗口);
('#Messagesub').html("You are Closing Window");


#Dialog)。dialog({
modal: true
可调整大小: false
按钮:{
Ok function (){
CloseWithWindowOpenTrick();
}
}
});
});

function CloseWithWindowOpenTrick(){
var objWindow = window .open( location .href, < span class =code-string> _ self);
objWindow.close();
}
("#Dialog").dialog({ modal: true, resizable: false, buttons: { "Ok": function () { CloseWithWindowOpenTrick(); } } }); }); function CloseWithWindowOpenTrick() { var objWindow = window.open(location.href, "_self"); objWindow.close(); }


这篇关于如何使用jquery关闭浏览器中的当前选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆