在Microsoft Edge中打开跨域窗口时将忽略window.open()参数 [英] window.open() parameters ignored when opening cross-origin window in Microsoft Edge

查看:392
本文介绍了在Microsoft Edge中打开跨域窗口时将忽略window.open()参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Microsoft Edge中,当 url 与当前域的来源不同时,以下代码片段将忽略传递给 window.open()的选项.但是可以正常运行,但在Chrome和Firefox以及域是相同来源的情况下都可以正常工作.

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 works it works fine in Chrome and Firefox, and when the domain is the same origin.

const popupWindow = window.open(
    url,
    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',
);

我发现了一个骇人的解决方法,可以正确调整窗口大小,但这确实很烦人,您可以看到它重定向了页面.

I found a hacky workaround to get the window to size properly but this is really annoying and you can see it redirect the page.

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;

如何在Microsoft Edge上进行此项工作?为什么Microsoft Edge忽略我的大小和其他参数?这是一个错误吗?

How do I make this work on Microsoft Edge? Why is Microsoft Edge ignoring my size and other parameters? Is this a bug?

推荐答案

我尝试检查此问题,它看起来像是与安全设置有关的问题.

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

我建议您修改以下 Internet选项设置.

I suggest you modify the below Internet Options settings.

(1)启用 跨域访问数据源选项.

Internet选项->安全性(Tab)->自定义级别->其他->跨域访问数据源->设置为已启用

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

(2)已禁用 保护模式.

Internet选项->安全性(Tab)->取消选中启用保护模式"互联网和本地Intranet

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

(3)将两个域都添加到受信任的站点列表.

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

Internet选项->安全性(Tab)->受信任的站点->站点->将两个域都添加到列表中.

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

(4)取消选中要求服务器验证(https:):

Internet选项->安全性(Tab)->受信任的站点->站点->取消选中需要服务器验证(https :)->输入localhost网址&点击添加按钮.

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',
);

Microsoft Edge 44.18362.1.0 中的输出:

这篇关于在Microsoft Edge中打开跨域窗口时将忽略window.open()参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆