window.open() parameters ignored when opening cross-origin window in Microsoft Edge

后端 未结 2 1116
抹茶落季
抹茶落季 2021-01-29 05:26

In Microsoft Edge, the following snippet will ignore the options passed to window.open() when url is a different origin than the current domain. But wo

相关标签:
2条回答
  • 2021-01-29 06:22

    I try to check the issue and it looks like security settings related issue.

    I suggest you modify the below Internet Options settings.

    (1) Enabled the Access data sources across domains option.

    Internet Options -> Security (Tab) -> Custom Level -> Miscellaneous -> Access data sources across domains -> Set to Enabled

    (2) Disabled the Protected mode.

    Internet Options -> Security (Tab) -> uncheck Enable Protected mode for Internet & Local Intranet

    (3) Add both domains to the trusted site list.

    Internet Options -> Security (Tab) -> Trusted sites -> Sites -> Add both domains to the list.

    (4) Uncheck Require server verification(https:):

    Internet Options -> Security (Tab) -> Trusted site -> Sites -> Uncheck Require server verification(https:) -> enter localhost url & click on add button.

    After modifying the above settings, I tested this code.

    const popupWindow = window.open(
        "https://Bing.com",
        "Microsoft page",
        'menu=no,toolbar=no,width=700,height=600,scrollbars=1,resizable=0,' +
            'directories=no,location=no,screenX=0,screenY=0,top=48,left=48',
    );
    

    Output in Microsoft Edge 44.18362.1.0 :

    0 讨论(0)
  • 2021-01-29 06:28

    For me it is working correctly so the problem may be the version of Edge you are using. You can use caniuse.com to check whether you can use things or not. However, since you have found this hacky way of using it you can turn it into a function like this:

       function popup(url, title){
         const popupWindow = window.open(
           "/#",
           title,
           'menu=no,toolbar=no,width=700,height=600,scrollbars=1,resizable=0,' +
           'directories=no,location=no,screenX=0,screenY=0,top=48,left=48',
         );
         popupWindow.location.href = url;
       }
    

    And now you can use the function popup.

    By the way, I can see you are using ES6. Make sure your version of Edge supports const.

    0 讨论(0)
提交回复
热议问题