Skip to content

windowMessagingTargetOrigin

Requires specifying the targetOrigin argument when calling window.postMessage().

✅ This rule is included in the browser logical preset.

When calling window.postMessage() without the targetOrigin argument, the message cannot be received by any window. The targetOrigin parameter specifies which origin is allowed to receive the message. Omitting this argument is a common mistake that prevents cross-window communication from working.

Always specify a target origin (for example, 'https://example.com' or '*' for any origin) as the second argument to postMessage().

window.postMessage("message");
self.postMessage("message");
parent.postMessage("message");
top.postMessage("message");

This rule is not configurable.

If you are developing a specialized internal application on a custom platform with unusual postMessage semantics, you may need to disable this rule.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.