最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JS showModalDialog not working in chrome as modal - Stack Overflow

programmeradmin2浏览0评论

I am using showModalDialog() in my application, for user to view articles from different sources as modal popup.

It work fine with FF and IE, but in chrome it's not behaving as modal, I can still go on parent window and click on any element in it.

I wanted to make it work same as IE and FF.

I have looked at few work-around

1) set onfocus event on parent window, and focus child again on it.

     <script type="text/javascript">
        setInterval(checkFocus, 10);
        var mywindow;
        function openModal() {
            var a = new Array;
            a[0] = 1;
            a[1] = 4;
            mywindow = window.showModalDialog(myurl,
      a, "dialogwidth: 1000; dialogheight: 700; resizable: yes;center : yes;");
        }

        function checkFocus() {
            if (mywindow != null && mywindow != undefined) {
                if (window.focus) {
                    mywindow.focus();
                }
            }
        }
      </script>

but this is not seems to work as expected.

2) set onblur event on child window, to focus itself again

this solution i have read from some online sources. i can apply this solution if only child window is customized page from on my domain only , but as my child window can be any url from any domain It is not applicable in my case.

I need to make it work , can anybody suggest me on this??

I am using showModalDialog() in my application, for user to view articles from different sources as modal popup.

It work fine with FF and IE, but in chrome it's not behaving as modal, I can still go on parent window and click on any element in it.

I wanted to make it work same as IE and FF.

I have looked at few work-around

1) set onfocus event on parent window, and focus child again on it.

     <script type="text/javascript">
        setInterval(checkFocus, 10);
        var mywindow;
        function openModal() {
            var a = new Array;
            a[0] = 1;
            a[1] = 4;
            mywindow = window.showModalDialog(myurl,
      a, "dialogwidth: 1000; dialogheight: 700; resizable: yes;center : yes;");
        }

        function checkFocus() {
            if (mywindow != null && mywindow != undefined) {
                if (window.focus) {
                    mywindow.focus();
                }
            }
        }
      </script>

but this is not seems to work as expected.

2) set onblur event on child window, to focus itself again

this solution i have read from some online sources. i can apply this solution if only child window is customized page from on my domain only , but as my child window can be any url from any domain It is not applicable in my case.

I need to make it work , can anybody suggest me on this??

Share Improve this question asked Jan 18, 2013 at 12:36 meghanameghana 9071 gold badge20 silver badges46 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

Chrome has serious bugs with its implementation. Most importantly the window Chrome displays isn’t modal (see Chromium bug #16045), meaning, the user is able to interact with the original window before dealing with the modal dialog.

发布评论

评论列表(0)

  1. 暂无评论