Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Close button on web form

Reply
Thread Tools

Close button on web form

 
 
Ron Lautmann
Guest
Posts: n/a
 
      06-10-2004
I want to close a browser window so I created a Close button that does this:

private void Button1_Click(object sender, System.EventArgs e)
{
RegisterClientScriptBlock("GetData","<Script>close ()</Script>");
}

But when this runs the browser puts up a dialog box saying: "The web page
you are viewing is trying to close the window, od you want to close this
window?"

Is there a way to close a browser window without this dialog box?


 
Reply With Quote
 
 
 
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      06-11-2004
HI Ron,

No, there is no way of doing this. The only windows you can close with any
notification are the windows that your browser create.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ron Lautmann" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I want to close a browser window so I created a Close button that does

this:
>
> private void Button1_Click(object sender, System.EventArgs e)
> {
> RegisterClientScriptBlock("GetData","<Script>close ()</Script>");
> }
>
> But when this runs the browser puts up a dialog box saying: "The web page
> you are viewing is trying to close the window, od you want to close this
> window?"
>
> Is there a way to close a browser window without this dialog box?
>
>



 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      06-11-2004
> No, there is no way of doing this. The only windows you can close with
any
> notification are the windows that your browser create.


Not true! The window.close() method checks to see if the opener property of
the window is null (meaning that it was not spawned by another browser
window). If you set the opener property to the window itself, it closes
without a prompt:

window.opener = self;
window.close();

Try it!

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:(E-Mail Removed)...
> HI Ron,
>
> No, there is no way of doing this. The only windows you can close with

any
> notification are the windows that your browser create.
>
> Cheers,
>
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
> "Ron Lautmann" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I want to close a browser window so I created a Close button that does

> this:
> >
> > private void Button1_Click(object sender, System.EventArgs e)
> > {
> > RegisterClientScriptBlock("GetData","<Script>close ()</Script>");
> > }
> >
> > But when this runs the browser puts up a dialog box saying: "The web

page
> > you are viewing is trying to close the window, od you want to close this
> > window?"
> >
> > Is there a way to close a browser window without this dialog box?
> >
> >

>
>



 
Reply With Quote
 
Ron Lautmann
Guest
Posts: n/a
 
      06-11-2004
That solution works well! Thanks for the info.

Ron Lautmann


"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> > No, there is no way of doing this. The only windows you can close with

> any
> > notification are the windows that your browser create.

>
> Not true! The window.close() method checks to see if the opener property

of
> the window is null (meaning that it was not spawned by another browser
> window). If you set the opener property to the window itself, it closes
> without a prompt:
>
> window.opener = self;
> window.close();
>
> Try it!
>
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>

wrote
> in message news:(E-Mail Removed)...
> > HI Ron,
> >
> > No, there is no way of doing this. The only windows you can close with

> any
> > notification are the windows that your browser create.
> >
> > Cheers,
> >
> > --
> > Ignacio Machin,
> > ignacio.machin AT dot.state.fl.us
> > Florida Department Of Transportation
> >
> > "Ron Lautmann" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > I want to close a browser window so I created a Close button that does

> > this:
> > >
> > > private void Button1_Click(object sender, System.EventArgs e)
> > > {
> > > RegisterClientScriptBlock("GetData","<Script>close ()</Script>");
> > > }
> > >
> > > But when this runs the browser puts up a dialog box saying: "The web

> page
> > > you are viewing is trying to close the window, od you want to close

this
> > > window?"
> > >
> > > Is there a way to close a browser window without this dialog box?
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      06-14-2004
Hi Kevin,

Thanks for the tips, I had never imagined that, I think this is something
MS needs to change, it allow a rogue page to close my browser without a
warning.

I had always thought it was not possible

Thank again,


--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> > No, there is no way of doing this. The only windows you can close with

> any
> > notification are the windows that your browser create.

>
> Not true! The window.close() method checks to see if the opener property

of
> the window is null (meaning that it was not spawned by another browser
> window). If you set the opener property to the window itself, it closes
> without a prompt:
>
> window.opener = self;
> window.close();
>
> Try it!
>
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>

wrote
> in message news:(E-Mail Removed)...
> > HI Ron,
> >
> > No, there is no way of doing this. The only windows you can close with

> any
> > notification are the windows that your browser create.
> >
> > Cheers,
> >
> > --
> > Ignacio Machin,
> > ignacio.machin AT dot.state.fl.us
> > Florida Department Of Transportation
> >
> > "Ron Lautmann" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > I want to close a browser window so I created a Close button that does

> > this:
> > >
> > > private void Button1_Click(object sender, System.EventArgs e)
> > > {
> > > RegisterClientScriptBlock("GetData","<Script>close ()</Script>");
> > > }
> > >
> > > But when this runs the browser puts up a dialog box saying: "The web

> page
> > > you are viewing is trying to close the window, od you want to close

this
> > > window?"
> > >
> > > Is there a way to close a browser window without this dialog box?
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Submit button to also close popup form Neil HTML 6 09-02-2011 06:42 PM
How to close a TCP socket? (TCPSocket#close doesn't close it) IƱaki Baz Castillo Ruby 7 01-12-2010 01:32 PM
Gmail: the Back button (vs. Close button)...onBeforeUnload? allan.young@gmail.com Javascript 5 03-22-2007 09:50 PM
close child form when parent form is closed. =?Utf-8?B?UGF1bA==?= ASP .Net 2 11-24-2004 10:31 AM
How to close child browser while parent close? Denon ASP .Net 1 11-14-2003 08:14 AM



Advertisments