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

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

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745397033a4625926.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信