I am opening a window with the showModalDialog method. The page has two buttons on it, Yes and No. For the onclick event of each button I have this code: onclick="done('Yes') - or - onclick="done('No') Here is the done function in JScript: function done(decision) { window.returnValue = decision; window.close; } But the window does not close! It does not give any error, either. I even tried swapping the position of the two lines (calling close first); it still does not close. If I manually close it after clicking a button (regardless of the order of the two statements), it correctly passes the return value to the caller. Does anyone have any idea why this isn't working? Thanks!
"Ron Hinds" wrote in message news:Oo3jVn64IHA.3784@TK2MSFTNGP06.phx.gbl > function done(decision) > { > window.returnValue = decision; > window.close; > } Surely you want window.close() (note the pair of parens). -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
"Igor Tandetnik" wrote in message news:%23Hv2S194IHA.4492@TK2MSFTNGP04.phx.gbl... > "Ron Hinds" wrote in message > news:Oo3jVn64IHA.3784@TK2MSFTNGP06.phx.gbl >> function done(decision) >> { >> window.returnValue = decision; >> window.close; >> } > > Surely you want window.close() (note the pair of parens). Unfortunately, it doesn't work that way, either ;-(
Ron Hinds wrote: > "Igor Tandetnik" wrote in message > news:%23Hv2S194IHA.4492@TK2MSFTNGP04.phx.gbl... >> "Ron Hinds" wrote in message >> news:Oo3jVn64IHA.3784@TK2MSFTNGP06.phx.gbl >>> function done(decision) >>> { >>> window.returnValue = decision; >>> window.close; >>> } >> >> Surely you want window.close() (note the pair of parens). > > Unfortunately, it doesn't work that way, either ;-( Works for me just fine. I've tested it with this (saved as test.html): <html> <head> <script language="javascript"> function showDialog() { window.showModalDialog("test.html"); } function done() { window.close(); } </script> </head> <body> <button onclick="showDialog();">Open dialog</button> <br> <button onclick="done();">Close window</button> </body> </html> -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925