Avatar of Nrupendra Nath Panigrahi
Nrupendra Nath Panigrahi

asked on 

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://example.com') does not match the recipient window's origin ('http://example.com').

I am using postMassage for communicating two different server data  using iframe. But i got an  Error Message


Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://domain.com') does not match the recipient window's origin ('http://domain.com').

In child domain Code

 window.parent.window.postMessage(
                    {'func': 'enquirydata', 'params': [pdata]},
            'http://example.com/'
                    );

Parent page Code



    function enquirydata(event) {
       
        var data = event.data;
        if (typeof (window[data.func]) == "function") {
            window[data.func].call(null, data.params[0]);
        }
    }
JavaScriptWeb Development

Avatar of undefined
Last Comment
Nrupendra Nath Panigrahi
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Can you post a link to your page please.  Something must not be right with the links you are using for the iframe and parent.  If you have sensitive data, please make a test  page with fake data.
ASKER CERTIFIED SOLUTION
Avatar of Nrupendra Nath Panigrahi
Nrupendra Nath Panigrahi

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Nrupendra Nath Panigrahi
Nrupendra Nath Panigrahi

ASKER

window.parent.window.postMessage(
                    {'func': 'enquirydata', 'params': [pdata]},
            'http://example.com/'
                    );

the code is working fine and there is some mismatching with domain
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo