firefox does not close window

Last Reply on Jun 11, 2012 10:55 PM By Amit

Posted on Jun 08, 2012 07:49 AM

I use javascript on my vb page,it is working fine in IE and chrome but not in firefox ........

 Page.ClientScript.RegisterStartupScript(Me.GetType(), "asr4", "var win=window.open('','_self');win.close();", True)

I also use

 

function winClose()
{
window.top.opener=null;
window.close();
}

or

function closeWindow()
{
window.open('','_parent',''); 
window.close();
}
But non of these is working in firefox..............
Posted on Jun 08, 2012 07:51 AM

All the scripts you are trying are meant to close browser without giving confirmation box to user. But this trick works only in IE and not in FireFox hence simply use

Page.ClientScript.RegisterStartupScript(Me.[GetType](), "asr4", "window.close();", True)

 


Posted on Jun 10, 2012 11:39 PM

This is not even working in chrome


Posted on Jun 11, 2012 05:11 AM

But it works in FireFox and IE


Posted on Jun 11, 2012 10:55 PM Modified on on Jun 11, 2012 11:04 PM

It works in IE but not in firefox and chrome..........check my code below :

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        

        Dim host As System.Net.IPHostEntry

        host = System.Net.Dns.GetHostByAddress(Request.ServerVariables.Item("REMOTE_HOST"))

 

        strHostName = host.HostName.ToLower()

        strHostIP = System.Net.Dns.GetHostEntry(strHostName).AddressList(0).ToString()

 

        If Not (strHostName = "ved1" Or strHostName = "amit" Or strHostName = "deepak" Or strHostName = "santos" Or strHostName = "shafeeq1") Then

            'Page.ClientScript.RegisterStartupScript(Me.[GetType](), "asr4", "alert('Dear " + strHostName.ToUpper() + " you dont have permission to access this page');var win=window.open('','_self');win.close();", True)

            Page.ClientScript.RegisterStartupScript(Me.[GetType](), "asr4", "window.close();", True)

            txtedit.Visible = False

            Exit Sub

        End If

 

First dark/highlighted portion works in Chrome and IE and second one work's only in IE

 

        user.Text = "Welcome " + strHostName

        user.Visible = True

 

        If Not IsPostBack Then

            bindgrid()

        End If

 

    End Sub