Window.opener in Microsoft Edge undefined when running at localhost

本秂侑毒 提交于 2019-12-20 03:40:09

问题


I'm using Microsoft Edge in localhost for development.

Website is accessed via http://localhost

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

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

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


回答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




回答2:


Microsoft Edge runs in network isolation and does not currently support localhost testing. Run this in an elevated command prompt to enable loopback support:

CheckNetIsolation LoopbackExempt -a -n=Microsoft.MicrosoftEdge_8wekyb3d8bbwe

In a future update, you’ll be able to enable localhost loopback support using about:flags.

More info: http://dev.modern.ie/platform/faq/how-can-i-debug-localhost/



来源:https://stackoverflow.com/questions/31196295/window-opener-in-microsoft-edge-undefined-when-running-at-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!