Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > ASP.NET

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-07-2008, 09:46 PM
=?Utf-8?B?UGF1bA==?=
 
Posts: n/a
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.
Reply With Quote
  #2 (permalink)  
Old 10-07-2008, 10:12 PM
Gustavo Cantero
 
Posts: n/a
Re: close webform java script

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:Paul@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.

Reply With Quote
  #3 (permalink)  
Old 10-07-2008, 11:23 PM
Mark Rae [MVP]
 
Posts: n/a
Re: close webform java script

"Gustavo Cantero" <g.cantero@scientia.com.ar> wrote 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

Reply With Quote
  #4 (permalink)  
Old 10-07-2008, 11:54 PM
=?Utf-8?B?UGF1bA==?=
 
Posts: n/a
Re: close webform java script

Thanks for the responses, do I just attatch this to the onclick event?
--
Paul G
Software engineer.


"Mark Rae [MVP]" wrote:

> "Gustavo Cantero" <g.cantero@scientia.com.ar> wrote 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
>
>

Reply With Quote
  #5 (permalink)  
Old 10-08-2008, 12:18 AM
Ben Amada
 
Posts: n/a
Re: close webform java script

Mark Rae [MVP] wrote:

> "Gustavo Cantero" <g.cantero@scientia.com.ar> wrote 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().

Reply With Quote
  #6 (permalink)  
Old 10-08-2008, 04:01 AM
bruce barker
 
Posts: n/a
Re: close webform java script

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.cantero@scientia.com.ar> wrote 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().

Reply With Quote
  #7 (permalink)  
Old 10-08-2008, 05:20 AM
Ben Amada
 
Posts: n/a
Re: close webform java script

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

Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > ASP.NET


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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



All times are GMT. The time now is 10:35 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
LCD TV | Online Loans | Credit Cards | Actress | Health 2007



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114