473,748 Members | 4,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Close button on web form

I want to close a browser window so I created a Close button that does this:

private void Button1_Click(o bject sender, System.EventArg s e)
{
RegisterClientS criptBlock("Get Data","<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?
Nov 18 '05 #1
4 6323
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" <ro************ *******@pacbell .net> wrote in message
news:el******** ******@tk2msftn gp13.phx.gbl...
I want to close a browser window so I created a Close button that does this:
private void Button1_Click(o bject sender, System.EventArg s e)
{
RegisterClientS criptBlock("Get Data","<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?

Nov 18 '05 #2
> 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.mach in AT dot.state.fl.us > wrote
in message news:uG******** ******@TK2MSFTN GP09.phx.gbl... 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" <ro************ *******@pacbell .net> wrote in message
news:el******** ******@tk2msftn gp13.phx.gbl...
I want to close a browser window so I created a Close button that does

this:

private void Button1_Click(o bject sender, System.EventArg s e)
{
RegisterClientS criptBlock("Get Data","<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?


Nov 18 '05 #3
That solution works well! Thanks for the info.

Ron Lautmann
"Kevin Spencer" <ks******@takem pis.com> wrote in message
news:Ol******** ******@TK2MSFTN GP09.phx.gbl...
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.mach in AT dot.state.fl.us > wrote in message news:uG******** ******@TK2MSFTN GP09.phx.gbl...
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" <ro************ *******@pacbell .net> wrote in message
news:el******** ******@tk2msftn gp13.phx.gbl...
I want to close a browser window so I created a Close button that does

this:

private void Button1_Click(o bject sender, System.EventArg s e)
{
RegisterClientS criptBlock("Get Data","<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?



Nov 18 '05 #4
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" <ks******@takem pis.com> wrote in message
news:Ol******** ******@TK2MSFTN GP09.phx.gbl...
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.mach in AT dot.state.fl.us > wrote in message news:uG******** ******@TK2MSFTN GP09.phx.gbl...
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" <ro************ *******@pacbell .net> wrote in message
news:el******** ******@tk2msftn gp13.phx.gbl...
I want to close a browser window so I created a Close button that does

this:

private void Button1_Click(o bject sender, System.EventArg s e)
{
RegisterClientS criptBlock("Get Data","<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?



Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2743
by: marcelf3 | last post by:
Hello.. This page opens a window with some information, but everytime the user changes a field in the parent window, the child window needs to be closed. These 2 functions were supposed to do the work. Nota() - opens new window. fechaNota() - closes the window opened by Nota() here is the code.
5
2725
by: Reggie | last post by:
Hi and TIA! I have a form and have set the Close Button to false so that users must exit using my close button. However when I open a Report from this form I want the close button to be available from the report print preview window. However, the first time I open the report to preview it the close button (X) in upper right hand corner is there. When I close the preview and open it again it is not there unless I close the app down and...
2
1626
by: Bert Szoghy | last post by:
Hello, I am missing something about Visual Basic .NET module variables and window close events. In the following code, after opening Form2 by clicking a button on Form1 and then closing Form2, I would expect to click on the second Form1 button and get intMyValue = 0. Form2 has code to reinitialize it in its close event, but this doesn't seem
3
4431
by: rdemyan via AccessMonster.com | last post by:
I need help with code to close two forms at the same time, FormA and FormB. I need code that can be used from either form and needs to work with both a 'Close' button on each form as well as if the user clicks the 'X' in the control box. I have a function, IsObjectOpen, that can be used to check if a form is open. The function is used as follows: X = IsObjectOpen(FormName,2)
4
10990
by: polocar | last post by:
Hi, I would like to find a way in C# so that, when the user presses the "Esc" key, the form closes; the problem is that I have a lot of controls in the form. At the beginning I have tried with the following form event handler: protected override void OnKeyPress(KeyPressEventArgs e) { base.OnKeyPress(e);
4
3516
by: mhifd009 | last post by:
I have disabled a close button in the property section of a form (FRM1), as i open the form the close button has gone (i have programmed close button), but as i close the form, the form that opened FRM1 also has the close button disabled - and so does every form until i minimise a form and maximise again. I have also tried to disable controlbox property but doesnt seem to remove, min, max or close - is there somewhere else i need to set. ...
3
10577
by: kev | last post by:
Hi folks, I have a form for registration (frmRegistration) whereby i have two buttons. One is Save which saves record using the OnClick property. I used wizard to create the save button. The other one is Next button which i created to open another form "frmSummary" which displays back the records submitted. (i used the wizard to open form and find specific records to display. All these works superb until a review by users where they...
2
4328
by: Del | last post by:
I have a popup form that consist of a single field called EnteredBy and a Subform that has three fields. The popup form also has a button in the Form Footer called close. In the On Click event I have the following code. DoCmd.Close I want the EnteredBy field to be a required field. So in the On Exit event for that field I have the following code.
2
3362
by: Bruce | last post by:
Hello, I have a form in an Access 2003 application which opens maximized. Its CloseButton property is set to false. On this form I have a command button that opens a report in preview mode. The report opens fine. It opens maximized as one would expect. However, the report preview window's close button is disabled which is confusing to my users (they have to click the resize button on the preview window which then restores the close...
7
2918
by: Sin Jeong-hun | last post by:
I have a dialog form which pops up from the main window using the ShowDialog() method. this dialog has no or button, and it has quite a lot of controls on it. Now, I want to close this dialog form when the user presses the escape key, but that's only when no control on the form is responsible for the escape key. For example, it has a ComboBox control, and a user can press the escape key just to close the drop down list that is being...
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8242
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.