I have a SP UIModal Pop-Up, in which I have a javascript code with alert. When I click OK in my alert, my pop-up should close...

Currently , I am closing the alert message, then I need to close the model dialog using the close [X] button. But my requirement is that the model dialog should close automatically once my alert is closed.

  • How to show alert when user click on close [X] ? can you share this logic? – Admin Sep 7 '16 at 6:14

Add one of these functions after your alert:

window.frameElement.commitPopup() //passes SP.UI.DialogResult.OK back
window.frameElement.cancelPopUp() //passes SP.UI.DialogResult.Cancel back
  • Thanks . But this option is working fine only in IE 8 + & Mozilla Firefox , but not in Chrome & Safari. As MS prescribes only IE ,I'm escaped. Is there any workaround to make it work for Chrome ? – Bashya Rajan Sep 6 '16 at 14:32
  • Hmm that's strange. Just tested it in Chrome 52 and it works. Can't test Safari, though. Maybe there's another issue with your code. – Daniel Stölzner Sep 6 '16 at 15:23
  • If my code is having any other issue then how could it work perfectly in IE & Firefox ?? Also I had given alerts in ExecuteQueryAsync(); both succeeded & Failed.. When I run in chrome , my Query is failing and the alert under failed() is displayed.. But not in IE ...!!!! Miraculous Issue :D – Bashya Rajan Sep 6 '16 at 15:27
  • How about you provide your code and I'll have a look at it? – Daniel Stölzner Sep 6 '16 at 15:30

Inspect the element close[X], find the Id and call click event using jquery. Something like


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.