Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to disable the close(cross) button of a window

 
Gaurav Goyal
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am opening a window using window.open. I want to disable the close(cross)(X) button which appears on the right hand top corner of the window.
I tried
window.open(popurl,"","width=1000,height=700,titlebar=0,top=5,left=5,screenX=100,screenY=100");
and
window.open(popurl,"","width=1000,height=700,titlebar='NO',top=5,left=5,screenX=100,screenY=100");
but none works as desired.
In the specs at w3schools.com I found

===========================================================================
titlebar = yes | no | 1 | 0
whether to display the title bar. Ignored unless the calling application is an HTML Application or a trusted dialog box. Default is yes
===========================================================================

I am calling this from a JSP of the same application.
Please help. Thanks in Advance.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't.
You don't own the user's desktop and shouldn't try to prevent the user from managing his/her own windows.
Webapps need to be written with the assumption that the user could leave at any time.
 
Gaurav Goyal
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright. So is there any particular event which specifically gets called only when the close(cross)(X) button is clicked.
The onUnload event gets called on the click of this button but is also called when the form is submitted(rather than a solution this becomes a problem).
 
Debashree Halder
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out this piece of code: It resizes the window to full screen. Hence you will not get any cross button

 
vaibhav anubhav
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do one thing. When any user close you window, a new window will open, that will content same thing.
 
Gaurav Goyal
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Debashree this works & solves my purpose. But wanted to know the purpose of || w.resizeTo ( 300, 200 ); || here, as its presence or absence or a diff set of arguments is not affecting the output. Pls correct me if I am wrong, I guess it is not working as we have already set the resizable property of window as 'no'.
My purpose is solved but would be thankful if someone can tell about the specific event which is called on the click of close(cross)(X) button.
 
Debashree Halder
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was part of the whole code...u can neglect that. No probs....
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vaibhav anubhav:
You can do one thing. When any user close you window, a new window will open, that will content same thing.


That is an obnoxious thing to do.
Most people, upon encountering this irritating behaviour, will immediately dismiss your app as a low grade, poorly written, and possibly dangerous site.

Also most browsers offer protection from popups instanciated from onLoad or onUnload function calls.

In any case none of this has anything to do with JSP so I'm going to move the thread to HTML/Javascript.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Debashree Halder:
Check out this piece of code: It resizes the window to full screen. Hence you will not get any cross button



Um, if that works on your computer, you really need to download a service pack. That bug has been fixed for years.

Eric
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not going to be able to do it. Why are you doing this in the first place. Use an iframe dynamiclaly poisitioned over the content on the page. No need for a pop up window, no close button issue, etc.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:

That is an obnoxious thing to do.


It sure it! The first time a web site does this to me, will be the last!
 
Rusty Smythe
Ranch Hand
Posts: 93
Mac Objective C Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
Most people, upon encountering this irritating behaviour, will immediately dismiss your app as a low grade, poorly written, and possibly dangerous site.


If I had to use that app (maybe because of work), then I'd solve that irritating problem once and for all by applying a liberal dose of GreaseMonkey.

As others have pointed out, there is no way to control anything on a user's computer. HTML code is nothing more than SUGGESTIONS to the user's browser. Knowing this is what seperates the script kiddies from professional web developers.
 
Gaurav Goyal
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The iframe will not help with that. This really is a job for user training if it is in in house application and session end on the server.

Eric
[ August 18, 2006: Message edited by: Eric Pascarello ]
 
Peter Chase
Ranch Hand
Posts: 1970
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a very similar situation. I ended up using XmlHttpRequest to ping the server periodically, so the server could tell my window was still open. When the server stops receiving pings, it knows it can clean up.

If the user presses *our* Close button, the clean up happens straight away. If they press the *browser's* Close button, the clean up has to wait for a time-out. As ours is an intranet Web application, we don't have to make the time-out terribly long. On a true internet Web application, the time-out would have to be quite long, to allow for rubbish connections etc.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic