Window.Close not working

  • Thread starter Thread starter John Talli
  • Start date Start date
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
 
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();}
}
 
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)
 
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.
 
Back
Top