Window.Close not working

J

John Talli

I have a button on the aspx page. <SAVE>

When I click it the Code Behind is called (see below) and the
JavaScript windows CONFIRM box works.

BUT the browser window never closes. Why?
Can anyone offer suggestions?
Thanks

JavaScript
-------------
function AssignContent() {
confirm('See if this popup happens.'); <<< This popups on the button click
window.close();
}


CodeBehind
 
J

John Kotuby

This is just a guess, but I believe that the confirm popup may be returning
a true or false effectively ending processing of the function.

Try replacing the confirm with alert and see if the window closes.

If you want user confirmation then place the window.close() inside a
conditional statement.

function AssignContent() {
if (confirm('Close the Window?'))
{ window.close();}
}
 
B

bruce barker

javascript can only close a window if it is a popup (has an opener).
there was a security hole where you could set opener, then call close,
but this is fixed in most browsers.

-- bruce (sqlwork.com)
 
J

John Talli

As it turns-out, the entire problem was related by the JavaScript library Prototype.
Apparently, some JavaScript regular commands just don't work in Prototype. I haven't
looked closely at it, and it almost seems unbelievable, but it appears that some
commands OVERRIDE JavaScript regular commands and then generate an error if you use
them.
 

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,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top