I am opening popup modal with below JavaScript code, which is working correctly. But is it possible that when modal dialog opens, cursor or focus should be on modal dialog rather than on parent page.

Please note that modal dialog have only text

javascript:OpenPopUpPage("../Pages/XXX.aspx", null, Width, Height)
  • is there any specific reason for not using SharePoint modal Dialog? – Amit Dec 7 '16 at 6:07
  • Yea there are big chuck of text like policy, terms and condition which we can show directly. So we need modal dialog – Milind Dec 7 '16 at 6:12

Add below div and style to parent page

<div id="dlgpopup" class="ms-dlgOverlay" style="display:none; z-index: 1504; width: 100%; height:100%;"></div>

.ms-dlgOverlay {
     position: absolute;
     top: 0px;
     left: 0px;
     width: 100%;
     height: 100%;
     opacity: 0.4;
     background-color: #999;
     display: none; 
} </style>

Set z-index:1505 to your dialog box

Add below script before open modal popup

document.getElementById("dlgpopup").style.display = 'block';
|improve this answer|||||
  • Thanx Viraj for your reply. So do you mean by all should go in parent page – Milind Dec 7 '16 at 6:59
  • Yes, after applying this, it will highlight your modal popup.\ – Viraj Gorajia Dec 7 '16 at 7:04
  • @viraj-gorjia this custom modal dialog, it is not SharePoint 2013 modal dialog. I was looking for the solution for SharePoint 2013 modal dialog box – Milind Dec 7 '16 at 8:25

I could solve the issue as below, hope it helps to some else

$("#id").click(function () {
            OpenPopUpPage("XXX.aspx", null, null, null)
            setTimeout(setFocusModalDialog, 100);
            return false;
    function setFocusModalDialog() {
        var iframe = $(".ms-dlgFrame")[0];
|improve this answer|||||

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.