close window problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    close window problem

    When the user click the "Close Application" button, it will close the
    window. That window is not called by window.open(... ) before. However,
    when it calls window.close(), it pops up an dialog saying "The Web
    page you are viewing is trying to close the window. Do you want to
    close this window?" It that window is called by window.open(... ), and
    I call window.close(), this problem won't happen. Any ideas?? Thanks!!


    <html>
    <head>
    <script type="text/javascript">
    function closewindow()
    {
    alert("user closes the application..." );
    window.close();
    }
    </script>
    </head>
    <body>
    <P><INPUT type=button value="Close Application" name=btnCloseAp p
    onclick="closew indow()">
    </body>
    </html>
  • Ivo

    #2
    Re: close window problem

    "Matt" <jrefactors@hot mail.com> typed[color=blue]
    > window. That window is not called by window.open(... ) before. However,
    > when it calls window.close(), it pops up an dialog saying "The Web
    > page you are viewing is trying to close the window. Do you want to
    > close this window?" It that window is called by window.open(... ), and
    > I call window.close(), this problem won't happen. Any ideas?? Thanks!![/color]

    This is normal browser behaviour, intended to stop malevolent code from
    closing windows over which it has no authority. *Your code* can only close a
    window without warning if *your code* itself has opened it.
    HTH
    Ivo


    Comment

    • Randy Webb

      #3
      Re: close window problem

      Ivo wrote:
      [color=blue]
      > "Matt" <jrefactors@hot mail.com> typed
      >[color=green]
      >>window. That window is not called by window.open(... ) before. However,
      >>when it calls window.close(), it pops up an dialog saying "The Web
      >>page you are viewing is trying to close the window. Do you want to
      >>close this window?" It that window is called by window.open(... ), and
      >>I call window.close(), this problem won't happen. Any ideas?? Thanks!![/color]
      >
      >
      > This is normal browser behaviour, intended to stop malevolent code from
      > closing windows over which it has no authority. *Your code* can only close a
      > window without warning if *your code* itself has opened it.[/color]

      Perhaps you meant "Your code can only cloase a window without warning in
      certain scenarios/browsers"? And, that "You should not try to close a
      window you didn't open"?

      --
      Randy
      Chance Favors The Prepared Mind
      comp.lang.javas cript FAQ - http://jibbering.com/faq/

      Comment

      Working...