close window problem

M

Matt

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=btnCloseApp
onclick="closewindow()">
</body>
</html>
 
I

Ivo

Matt said:
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!!

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
 
R

Randy Webb

Ivo said:
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.

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

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,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top