473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

close webform java script

I am looking for a java script to close a web form that I can attatch to a
button click event. I am using vs2005, c#.
Thanks
--
Paul G
Software engineer.
Oct 7 '08 #1
6 3219
Paul:
The script "window.close()" close the window in the browser. Is this
that you need?

Gustavo A. Cantero
CEO - Scientia® Soluciones Informáticas
MCP - MCSD - MCTS
http://www.scientia.com.ar
http://www.programandoamedianoche.com
http://foro.scientia.com.ar

-----Mensaje original-----
De: Paul [mailto:Pa**@discussions.microsoft.com]
Expuesto a las: Martes, 07 de Octubre de 2008 05:46 p.m.
Expuesto en: microsoft.public.dotnet.framework.aspnet
Conversación: close webform java script
Asunto: close webform java script

I am looking for a java script to close a web form that I can attatch to a
button click event. I am using vs2005, c#.
Thanks
--
Paul G
Software engineer.

Oct 7 '08 #2
"Gustavo Cantero" <g.*******@scientia.com.arwrote in message
news:7A0F0A1B77EE4A3F932D1D235D10FF6F@CATALINA...

[top-posting corrected]
>I am looking for a java script to close a web form that I can attatch to
a
button click event. I am using vs2005, c#.

The script "window.close()" close the window in the browser. Is this
that you need?
That will generate a message asking the user to confirm that they want to
close the window, and you have omitted the final semi-colon.

The correct JavaScript is:

"window.opener=null;window.close();"
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 7 '08 #3
Thanks for the responses, do I just attatch this to the onclick event?
--
Paul G
Software engineer.
"Mark Rae [MVP]" wrote:
"Gustavo Cantero" <g.*******@scientia.com.arwrote in message
news:7A0F0A1B77EE4A3F932D1D235D10FF6F@CATALINA...

[top-posting corrected]
I am looking for a java script to close a web form that I can attatch to
a
button click event. I am using vs2005, c#.
The script "window.close()" close the window in the browser. Is this
that you need?

That will generate a message asking the user to confirm that they want to
close the window, and you have omitted the final semi-colon.

The correct JavaScript is:

"window.opener=null;window.close();"
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 7 '08 #4
Mark Rae [MVP] wrote:
"Gustavo Cantero" <g.*******@scientia.com.arwrote in message
news:7A0F0A1B77EE4A3F932D1D235D10FF6F@CATALINA...
>>I am looking for a java script to close a web form that I can attatch
to a button click event. I am using vs2005, c#.

The script "window.close()" close the window in the browser. Is this
that you need?

That will generate a message asking the user to confirm that they want
to close the window, and you have omitted the final semi-colon.

The correct JavaScript is:

"window.opener=null;window.close();"
That only appears to be the case with IE6.

In IE7, setting opener to null doesn't appear to make a difference. There
is a difference between closing a window that was opened by script versus
closing a window that was not opened by script. You're prompted with a
confirmation if closing a window that was _not_ opened by JavaScript. If
the window was opened by JavaScript, you're not prompted with a confirmation
(it just closes). Setting window.opener to null doesn't change this.

In Firefox, if you try to close a window that was not opened by JavaScript,
it doesn't close and you get the message "Warning: Scripts may not close
windows that were not opened by script." in the error console. If you close
a window that was opened by JavaScript, you're not prompted with a
confirmation (it just closes). This is true regardless of setting
window.opener to null.

In Safari 3.1, setting opener to null makes no difference. Windows opened
by script always close without a confirmation, and windows not opened by
script will not close with window.close().

Oct 7 '08 #5
setting opener to null was a trick that works due a (minor) security bug
with ie 6.0 (opener should be read only). no properly coded browser will
allow javascript to close a main (non popup) window, only windows that
were opened with javascript (and thus have an opener defined) will
respond to window.close().

-- bruce (sqlwork.com)

Ben Amada wrote:
Mark Rae [MVP] wrote:
>"Gustavo Cantero" <g.*******@scientia.com.arwrote in message
news:7A0F0A1B77EE4A3F932D1D235D10FF6F@CATALINA. ..
>>>I am looking for a java script to close a web form that I can attatch
to a button click event. I am using vs2005, c#.

The script "window.close()" close the window in the browser. Is this
that you need?

That will generate a message asking the user to confirm that they want
to close the window, and you have omitted the final semi-colon.

The correct JavaScript is:

"window.opener=null;window.close();"

That only appears to be the case with IE6.

In IE7, setting opener to null doesn't appear to make a difference.
There is a difference between closing a window that was opened by script
versus closing a window that was not opened by script. You're prompted
with a confirmation if closing a window that was _not_ opened by
JavaScript. If the window was opened by JavaScript, you're not prompted
with a confirmation (it just closes). Setting window.opener to null
doesn't change this.

In Firefox, if you try to close a window that was not opened by
JavaScript, it doesn't close and you get the message "Warning: Scripts
may not close windows that were not opened by script." in the error
console. If you close a window that was opened by JavaScript, you're
not prompted with a confirmation (it just closes). This is true
regardless of setting window.opener to null.

In Safari 3.1, setting opener to null makes no difference. Windows
opened by script always close without a confirmation, and windows not
opened by script will not close with window.close().
Oct 8 '08 #6
bruce barker wrote:
setting opener to null was a trick that works due a (minor) security bug
with ie 6.0 (opener should be read only). no properly coded browser will
allow javascript to close a main (non popup) window, only windows that
were opened with javascript (and thus have an opener defined) will
respond to window.close().
Aaah ... I wasn't aware of this issue with IE6. Another item on my "go away
IE6" list :)

Oct 8 '08 #7

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

Similar topics

2
by: Cathy | last post by:
Has anyone ever made a webform button run an onClick event that is a Javascript in the HTML code and then after running the script make it go into the code-behind? An HTML button will run the...
6
by: Phillip N Rounds | last post by:
I have a webform, from which I have to submit info to another site. Their instructions are to have a html form, with the following as the submit: <form method="post"...
3
by: trint | last post by:
Ok, I have tried to do this with the System.Web.UI and can't find anything for the webform. It seems much easier for a Winform. Any help in trapping Webform keydown event and keyup event is...
7
by: mg | last post by:
I need to first open WebForm2 from WebForm1 and then close WebForm1 without the end user having to press an OK button before the close can occur. For example, possibly ...
2
by: Ed Chiu | last post by:
Hi, I would like to add a <asp:button> to a webform. When user click on this button, the page will connect to SQL server and update tables, then the browser window will be closed. I know how...
3
by: Ipsita | last post by:
Hi, I am explaining the scenario of what I am trying to do: - I have a webform with some controls, from which I am taking the data. eg say Username, password - I am passing these data as...
14
by: Paul | last post by:
Hi I have 2 functions in java script, one opens a second window-this works, the other is supposed to close this second window, does not seem to be working. Just wondering if anyone had any ideas....
1
by: almurph | last post by:
Hi everyone, I have an APS.NET (v1.1) type button on a webform page. What I want it to do is when the user clicks it, it then calls another webform page that appears in a pop-up window. Now I...
15
by: Mahernoz | last post by:
Hi Friends, I simply want to print a report by opening a popup, calling the print function and closing the window after the user has printed the report. I have 2 functions.... in c# The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...

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.