Disabling the close button

J

Joakim Braun

lightzizo said:
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?)
 
T

Thomas 'PointedEars' Lahn

lightzizo said:
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
 
J

James

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
 
M

McKirahan

James said:
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>
 
J

James

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
 
W

web.dev

lightzizo said:
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?
 
T

Thomas 'PointedEars' Lahn

James said:
You may use javascript function attachEvent:

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

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
 
T

Thomas 'PointedEars' Lahn

McKirahan said:
James said:
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
 
R

Randy Webb

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?
 
L

lightzizo

Hello all
thanks for your replies

but actually I want to describe the situation here:
I'm opening a popup window from another popup and i don't want the user
to close the parent popup as long as the child is still opened.
I've thought about making the child to be modal screen but how can i do
that??
 
T

Thomas 'PointedEars' Lahn

lightzizo said:
I'm opening a popup window from another popup and i don't want the
user to close the parent popup as long as the child is still opened.
I've thought about making the child to be modal screen but how can
i do that??

You do not, that would only make your app less interoperable (IE only).
Returning a string to onbeforeunload is probably the best approach
here. Let the user decide whether or not the window should be closed.
[top post]

<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top