• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 93
Mac Objective C Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic