<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Error on accessing a cross-origin frame in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Error-on-accessing-a-cross-origin-frame/m-p/59323#M33916</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am hosting an add payment form inside my page and I am using ICommunicator.html from the authorize.net samle application. I am able to host the form but communication between iframe and parent is not happening and it throwing an error about&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;"&lt;IMG src="C:\Users\jshah\Desktop\authneterror.PNG" border="0" alt="" width="Infinity" /&gt;Uncaught DOMException: Blocked a frame with origin "&lt;A href="https://na.local.com" target="_blank"&gt;https://na.local.com&lt;/A&gt;" from accessing a cross-origin frame.&lt;BR /&gt;at callParentFunction (&lt;A href="https://na.local.com/ssl/checkout/iCommunicator.html:8:29" target="_blank"&gt;https://na.local.com/ssl/checkout/iCommunicator.html:8:29&lt;/A&gt;)&lt;BR /&gt;at &lt;A href="https://na.local.com/ssl/checkout/iCommunicator.html:28:4" target="_blank"&gt;https://na.local.com/ssl/checkout/iCommunicator.html:28:4&lt;/A&gt;".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason its not allowing to use the js function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is &amp;nbsp;how my ICommunicator.html looks like&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;BR /&gt; &amp;lt;head&amp;gt;&lt;BR /&gt; &amp;lt;title&amp;gt;IFrame Communicator&amp;lt;/title&amp;gt;&lt;BR /&gt; &amp;lt;script type="text/javascript"&amp;gt;&lt;BR /&gt;&lt;BR /&gt; function callParentFunction(str) {&lt;BR /&gt; if (str &amp;amp;&amp;amp; str.length &amp;gt; 0 &amp;amp;&amp;amp; window.parent &amp;amp;&amp;amp; window.parent.parent &lt;BR /&gt; &amp;amp;&amp;amp; window.parent.parent.CommunicationHandler &amp;amp;&amp;amp; window.parent.parent.CommunicationHandler.onReceiveCommunication)&lt;BR /&gt; {&lt;BR /&gt; var referrer = document.referrer;&lt;BR /&gt; window.parent.parent.CommunicationHandler.onReceiveCommunication({qstr : str , parent : referrer});&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; function receiveMessage(event) {&lt;BR /&gt; if (event &amp;amp;&amp;amp; event.data) {&lt;BR /&gt; callParentFunction(event.data);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; if (window.addEventListener) {&lt;BR /&gt; window.addEventListener("message", receiveMessage, false);&lt;BR /&gt; } else if (window.attachEvent) {&lt;BR /&gt; window.attachEvent("onmessage", receiveMessage);&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; if (window.location.hash &amp;amp;&amp;amp; window.location.hash.length &amp;gt; 1) {&lt;BR /&gt; callParentFunction(window.location.hash.substring(1));&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; &amp;lt;/script&amp;gt;&lt;BR /&gt; &amp;lt;/head&amp;gt;&lt;BR /&gt; &amp;lt;body&amp;gt;&lt;BR /&gt; &amp;lt;/body&amp;gt;&lt;BR /&gt; &amp;lt;/html&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and &amp;nbsp;I have added javascript in my code but its not hitting that because of that error.&lt;/P&gt;&lt;PRE&gt; ///&amp;lt;summary&amp;gt; authorize.net js&amp;lt;/summary&amp;gt;  
    window.CommunicationHandler = {};
    function parseQueryString(str) {
        var vars = [];
        var arr = str.split('&amp;amp;');
        var pair;
        for (var i = 0; i &amp;lt; arr.length; i++) {
            pair = arr[i].split('=');
            vars[pair[0]] = unescape(pair[1]);
        }
        return vars;
    }
    window.CommunicationHandler.onReceiveCommunication = function (argument) {


        var params = parseQueryString(argument.qstr);

        switch (params['action']) {
            case "resizeWindow":

                console.log('resize'); break;

            case "successfulSave":

                console.log('save'); break;

            case "cancel":

                console.log('cancel'); break;

            case "transactResponse":

                sessionStorage.removeItem("HPTokenTime");

                console.log('transaction complete');

                var transResponse = JSON.parse(params['response']);

                window.location.href = 'ssl/checkout/ReviewAndPay.aspx';

        }
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Julin&lt;/P&gt;</description>
    <pubDate>Thu, 10 Aug 2017 19:13:11 GMT</pubDate>
    <dc:creator>julin123</dc:creator>
    <dc:date>2017-08-10T19:13:11Z</dc:date>
    <item>
      <title>Error on accessing a cross-origin frame</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Error-on-accessing-a-cross-origin-frame/m-p/59323#M33916</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am hosting an add payment form inside my page and I am using ICommunicator.html from the authorize.net samle application. I am able to host the form but communication between iframe and parent is not happening and it throwing an error about&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;"&lt;IMG src="C:\Users\jshah\Desktop\authneterror.PNG" border="0" alt="" width="Infinity" /&gt;Uncaught DOMException: Blocked a frame with origin "&lt;A href="https://na.local.com" target="_blank"&gt;https://na.local.com&lt;/A&gt;" from accessing a cross-origin frame.&lt;BR /&gt;at callParentFunction (&lt;A href="https://na.local.com/ssl/checkout/iCommunicator.html:8:29" target="_blank"&gt;https://na.local.com/ssl/checkout/iCommunicator.html:8:29&lt;/A&gt;)&lt;BR /&gt;at &lt;A href="https://na.local.com/ssl/checkout/iCommunicator.html:28:4" target="_blank"&gt;https://na.local.com/ssl/checkout/iCommunicator.html:28:4&lt;/A&gt;".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason its not allowing to use the js function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is &amp;nbsp;how my ICommunicator.html looks like&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&amp;gt;&lt;BR /&gt; &amp;lt;head&amp;gt;&lt;BR /&gt; &amp;lt;title&amp;gt;IFrame Communicator&amp;lt;/title&amp;gt;&lt;BR /&gt; &amp;lt;script type="text/javascript"&amp;gt;&lt;BR /&gt;&lt;BR /&gt; function callParentFunction(str) {&lt;BR /&gt; if (str &amp;amp;&amp;amp; str.length &amp;gt; 0 &amp;amp;&amp;amp; window.parent &amp;amp;&amp;amp; window.parent.parent &lt;BR /&gt; &amp;amp;&amp;amp; window.parent.parent.CommunicationHandler &amp;amp;&amp;amp; window.parent.parent.CommunicationHandler.onReceiveCommunication)&lt;BR /&gt; {&lt;BR /&gt; var referrer = document.referrer;&lt;BR /&gt; window.parent.parent.CommunicationHandler.onReceiveCommunication({qstr : str , parent : referrer});&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; function receiveMessage(event) {&lt;BR /&gt; if (event &amp;amp;&amp;amp; event.data) {&lt;BR /&gt; callParentFunction(event.data);&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; if (window.addEventListener) {&lt;BR /&gt; window.addEventListener("message", receiveMessage, false);&lt;BR /&gt; } else if (window.attachEvent) {&lt;BR /&gt; window.attachEvent("onmessage", receiveMessage);&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; if (window.location.hash &amp;amp;&amp;amp; window.location.hash.length &amp;gt; 1) {&lt;BR /&gt; callParentFunction(window.location.hash.substring(1));&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; &amp;lt;/script&amp;gt;&lt;BR /&gt; &amp;lt;/head&amp;gt;&lt;BR /&gt; &amp;lt;body&amp;gt;&lt;BR /&gt; &amp;lt;/body&amp;gt;&lt;BR /&gt; &amp;lt;/html&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and &amp;nbsp;I have added javascript in my code but its not hitting that because of that error.&lt;/P&gt;&lt;PRE&gt; ///&amp;lt;summary&amp;gt; authorize.net js&amp;lt;/summary&amp;gt;  
    window.CommunicationHandler = {};
    function parseQueryString(str) {
        var vars = [];
        var arr = str.split('&amp;amp;');
        var pair;
        for (var i = 0; i &amp;lt; arr.length; i++) {
            pair = arr[i].split('=');
            vars[pair[0]] = unescape(pair[1]);
        }
        return vars;
    }
    window.CommunicationHandler.onReceiveCommunication = function (argument) {


        var params = parseQueryString(argument.qstr);

        switch (params['action']) {
            case "resizeWindow":

                console.log('resize'); break;

            case "successfulSave":

                console.log('save'); break;

            case "cancel":

                console.log('cancel'); break;

            case "transactResponse":

                sessionStorage.removeItem("HPTokenTime");

                console.log('transaction complete');

                var transResponse = JSON.parse(params['response']);

                window.location.href = 'ssl/checkout/ReviewAndPay.aspx';

        }
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Julin&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 19:13:11 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Error-on-accessing-a-cross-origin-frame/m-p/59323#M33916</guid>
      <dc:creator>julin123</dc:creator>
      <dc:date>2017-08-10T19:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error on accessing a cross-origin frame</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Error-on-accessing-a-cross-origin-frame/m-p/59346#M33938</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.developer.cybersource.com/t5/user/viewprofilepage/user-id/22159"&gt;@julin123&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The X-Frame-Options directives are deprecated, the modern alternative is the Content-Security-Policy header, which along with many other policies can white-list what URLs are allowed to host your page in a frame, using the frame-ancestors directive, frame-ancestors supports multiple domains and even wildcards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One way to resolve this issue on Apache is to use the following in your .htaccess file.&lt;/P&gt;&lt;PRE&gt;Header set Content-Security-Policy "frame-ancestors 'self' *.YOUR_WEBSITE.com *.authorize.net"&lt;/PRE&gt;&lt;P&gt;Or for a specific file:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;Files iCommunicator.html&amp;gt;
Header set Content-Security-Policy "frame-ancestors 'self' *.YOUR_WEBSITE.com *.authorize.net"
&amp;lt;/Files&amp;gt;&lt;/PRE&gt;&lt;P&gt;See a working example at :&amp;nbsp;&lt;A href="https://nexwebhost.com/authorizenet/gethosted.html" target="_blank"&gt;https://nexwebhost.com/authorizenet/gethosted.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 15:17:25 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Error-on-accessing-a-cross-origin-frame/m-p/59346#M33938</guid>
      <dc:creator>NexusSoftware</dc:creator>
      <dc:date>2017-08-11T15:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Error on accessing a cross-origin frame</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/Error-on-accessing-a-cross-origin-frame/m-p/65304#M38992</link>
      <description>&lt;P&gt;Thanks for the resolution. I am new to web deveopment, did not see much about whitelisting. Can you ellaborate little more on this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AM facing exactly same issue when using iframe. I am unable to white list. When we say header. which html&amp;nbsp;file header needs to be updated ?&amp;nbsp;Is it Icommunicator or the payment form contained page ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Am using asp.net/webforms)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Dec 2018 08:45:09 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/Error-on-accessing-a-cross-origin-frame/m-p/65304#M38992</guid>
      <dc:creator>mvkotekar1983</dc:creator>
      <dc:date>2018-12-08T08:45:09Z</dc:date>
    </item>
  </channel>
</rss>

