在本地运行时未定义Microsoft Edge中的Window.opener [英] Window.opener in Microsoft Edge undefined when running at localhost

查看:380
本文介绍了在本地运行时未定义Microsoft Edge中的Window.opener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地主机中使用Microsoft Edge进行开发.

I'm using Microsoft Edge in localhost for development.

通过http://localhost

我打开一个弹出窗口,并希望它通过window.opener.postMessage

I open a popup and want it to post a message to the opener via window.opener.postMessage

当网站处于暂定阶段或正式投入生产时,我的代码可与Chrome,Safari和Microsoft Edge一起使用.

My code works with Chrome, and Safari, and even Microsoft Edge when the website is on staging or production.

但是当我在本地模式下运行时,window.opener是不确定的.

But when I run in in local mode, the window.opener is undefined.

推荐答案

本地主机上的CORS很棘手,因此请尝试为主机文件创建一个您喜欢的域名(%windir%\ System32 \ Drivers \ etc \ hosts)-如果您使用的是基于Windows的平台,并将其映射回127.0.0.1.

CORS on localhost is tricky so try to create a domain name you like to your hosts file (%windir%\System32\Drivers\etc\hosts) - if you're in a Windows-based platform and map those back to 127.0.0.1.

您可能已经知道如何更改主机文件,但以防万一:

You probably already know how to change the hosts file but just in case:

http://support.hostgator.com/articles/general-help/technical/how-do-i-change-my-hosts-file

这篇关于在本地运行时未定义Microsoft Edge中的Window.opener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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