2

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.

4
  • When you say local mode I assume you mean file:/// instead of http://localhost - possible duplicate of JavaScript window.opener call parent function Commented Jul 2, 2015 at 23:37
  • No as I said, I'm running it through localhost, with the http:// Commented Jul 2, 2015 at 23:42
  • 4
    Then this is probably applicable: It is also not supported in IE if the opener is in a different security zone. from developer.mozilla.org/en-US/docs/Web/API/Window/opener Commented Jul 2, 2015 at 23:43
  • As I said, the code works well when ran in production, even ran with Edge, and the targetOrigin the message listener is set to '*' to be usable with a desktop app built with Electron. Both popup and main window are in http://localhost:9000 Commented Jul 2, 2015 at 23:49

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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/

1 Comment

I already configured this, as I said I can open popups so it means my code runs in localhost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.