Disabling the close button

Discussion in 'Javascript' started by lightzizo, Nov 29, 2005.

  1. lightzizo

    lightzizo Guest

    All,

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

    thanks
     
    lightzizo, Nov 29, 2005
    #1
    1. Advertising

  2. lightzizo

    Joakim Braun Guest

    "lightzizo" <> skrev i meddelandet
    news:...
    > 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
     
    Joakim Braun, Nov 29, 2005
    #2
    1. Advertising

  3. 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
     
    Thomas 'PointedEars' Lahn, Nov 29, 2005
    #3
  4. lightzizo

    James Guest

    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
     
    James, Nov 29, 2005
    #4
  5. lightzizo

    McKirahan Guest

    "James" <> wrote in message
    news:...
    > 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>
     
    McKirahan, Nov 29, 2005
    #5
  6. lightzizo

    James Guest

    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
     
    James, Nov 29, 2005
    #6
  7. lightzizo

    web.dev Guest

    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?
     
    web.dev, Nov 29, 2005
    #7
  8. 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
     
    Thomas 'PointedEars' Lahn, Nov 29, 2005
    #8
  9. McKirahan wrote:

    > "James" <> 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
     
    Thomas 'PointedEars' Lahn, Nov 29, 2005
    #9
  10. lightzizo

    Randy Webb Guest

    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/
     
    Randy Webb, Nov 29, 2005
    #10
  11. lightzizo

    lightzizo Guest

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




    Randy Webb wrote:
    > 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/
     
    lightzizo, Nov 30, 2005
    #11
  12. lightzizo wrote:

    > 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
     
    Thomas 'PointedEars' Lahn, Nov 30, 2005
    #12
  13. lightzizo

    James Guest

    Use JavaScript function:

    window.showModalDialog
     
    James, Nov 30, 2005
    #13
  14. James wrote:

    > Use JavaScript function:
    >
    > window.showModalDialog


    which is not a JavaScript function and is IE-only, so don't.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Nov 30, 2005
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JJ
    Replies:
    0
    Views:
    348
  2. Replies:
    2
    Views:
    794
    Jonathan N. Little
    May 15, 2008
  3. mrjava
    Replies:
    0
    Views:
    583
    mrjava
    Aug 4, 2008
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    921
    Iñaki Baz Castillo
    Jan 12, 2010
  5. Replies:
    5
    Views:
    328
Loading...

Share This Page