Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Disabling the close button

Reply
Thread Tools

Disabling the close button

 
 
lightzizo
Guest
Posts: n/a
 
      11-29-2005
All,

How can I disable or remove the close button in the screen.

thanks

 
Reply With Quote
 
 
 
 
Joakim Braun
Guest
Posts: n/a
 
      11-29-2005
"lightzizo" <(E-Mail Removed)> skrev i meddelandet
news:(E-Mail Removed) oups.com...
> All,
>
> How can I disable or remove the close button in the screen.
>
> thanks


You've been asking this question in various guises several times. The answer
is still "you can't".

If you think your application requires this functionality, you have
misunderstood the environment that your application has to work with. You
will therefore either have to redesign your application to work within those
limitations, or choose a different environment that lets you do what you
want (such as creating an application that's not browser-based).

(Even if you could remove the close button, how would your application deal
with, say, a forced-quit of the browser?)

--
Joakim Braun


 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      11-29-2005
lightzizo wrote:

> How can I disable or remove the close button in the screen.


Neither can you nor should you (attempt to).

Name the reasons why you think this is necessary, and you
will probably receive numerous replies why it is not.


PointedEars
 
Reply With Quote
 
James
Guest
Posts: n/a
 
      11-29-2005
You may use javascript function attachEvent:

function window.onload()
{
window.attachEvent("onbeforeunload", Close);
}

function Close()
{
return 'Are you sure you want to close my lovely window?'
}


If you think the anwser helps you, please show your support by visiting
my website:

http://www.logicwebsolutions.com

 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      11-29-2005
"James" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> You may use javascript function attachEvent:
>
> function window.onload()
> {
> window.attachEvent("onbeforeunload", Close);
> }
>
> function Close()
> {
> return 'Are you sure you want to close my lovely window?'
> }
>
>
> If you think the anwser helps you, please show your support by visiting
> my website:
>
> http://www.logicwebsolutions.com
>


Perhaps just the following?

<html>
<head>
<title>closer.htm</title>
<script type="text/javascript">
function closer() {
alert("This window is about to close.");
}
</script>
</head>
<body onbeforeunload="closer()">
</body>
</html>


 
Reply With Quote
 
James
Guest
Posts: n/a
 
      11-29-2005
If you do not have other functions to handle this event you approch is
fine.

BTW, you shoud use return instead of alert; by using return, the page
will stay
if the user clicks Cancel button from the popup window.

James
http://www.logicwebsolutions.com

 
Reply With Quote
 
web.dev
Guest
Posts: n/a
 
      11-29-2005

lightzizo wrote:
> All,
>
> How can I disable or remove the close button in the screen.
>
> thanks


Since others could not convince you, here's a solution you can attempt:

1. Learn a programming language
2. Create your own web browser application
3. Create a method in which you can remove / disable the close button
via script.

Simple, huh?

 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      11-29-2005
James wrote:

> You may use javascript function attachEvent:


attachEvent is neither a JavaScript nor a JScript function.
It is a method of the IE(4?) DOM.

<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/attachevent.asp>

> function window.onload()

-----------------^
SyntaxError: missing ( before formal parameters

> If you think the anwser helps you, please show your support by visiting
> my website:


YMMD!


PointedEars
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      11-29-2005
McKirahan wrote:

> "James" <(E-Mail Removed)> wrote [...]:
>> You may use javascript function attachEvent:
>>
>> function window.onload()
>> {
>> window.attachEvent("onbeforeunload", Close);
>> }
>>
>> function Close()
>> {
>> return 'Are you sure you want to close my lovely window?'
>> }
>>
>> [...]

>
> Perhaps just the following?
>
> <html>
> <head>
> <title>closer.htm</title>
> <script type="text/javascript">
> function closer() {
> alert("This window is about to close.");
> }
> </script>
> </head>
> <body onbeforeunload="closer()">
> </body>
> </html>


In contrast to your solution, James', even though it has its bugs, allows
the user to cancel the unload-Event in IE an Mozilla/5.0 if corrected (and
it does not make a successful attempt in providing invalid HTML). However,
I am not sure whether selecting "Cancel" would also prevent closing the
window.


PointedEars
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      11-29-2005
James said the following on 11/29/2005 1:25 PM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.


> You may use javascript function attachEvent:
>
> function window.onload()
> {
> window.attachEvent("onbeforeunload", Close);
> }
>
> function Close()
> {
> return 'Are you sure you want to close my lovely window?'
> }


That does absolutely nothing to stop me from closing the browser. In
fact, it only makes me *more* determined to leave your site. I am
leaving, let me go in Peace.

> If you think the anwser helps you, please show your support by visiting
> my website:


I hope your website has better advice than you give here.

For example, does it explain that in Usenet you should quote what you
are replying to?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
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
How to close a TCP socket? (TCPSocket#close doesn't close it) IƱaki Baz Castillo Ruby 7 01-12-2010 01:32 PM
Disabling [x] button and handling the window close event mrjava Java 0 08-04-2008 10:40 AM
disabling the ENTER button to trigger a button? paul814@excite.com HTML 2 05-15-2008 03:28 PM
Gmail: the Back button (vs. Close button)...onBeforeUnload? allan.young@gmail.com Javascript 5 03-22-2007 09:50 PM
disabling close verb from a user control that implements IWebPart JJ ASP .Net 0 03-22-2007 02:21 PM



Advertisments