seniorHTML5

What is the 'Window.postMessage()' method used for?

Updated Apr 28, 2026

Short answer

It allows cross-origin communication between windows or iframes.

Deep explanation

Normally, scripts on different origins cannot communicate due to the Same-Origin Policy. postMessage provides a secure way to bypass this by sending data packets that the receiving window can listen for.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More HTML5 interview questions

View all →