Skip to main content
Notice removed Canonical answer required by CommunityBot
Bounty Ended with no winning answer by CommunityBot
added 295 characters in body; edited tags
Source Link
Nagendra K S
  • 385
  • 1
  • 6
  • 20

Javascript on VF page:

    function openInSubtab(asd, asdf) {
            sforce.console.getEnclosingPrimaryTabId(function (r) {
                callBackopenTab(r, asd, asdf);
            });
    }

    function callBackopenTab(r, asd, asdf) {
        console.log('rId : ' + r.id);
        console.log('asd: ' + asd);
        console.log('asdf: ' + asdf);
        sforce.console.openSubtab(r.id, '/' + asd, true, asdf, null);
    }

VF page link:

<a href="javascript:void(0);"openInSubtab('{!asd', '{!asdf');return false;">{!asd}</a>

This works fine when its a VF page and we include this into a flexipage. Now I have embedded this VF page in a lightning component via an iframe.

<iframe id="componentName" src="/apex/VFPAGENAME" width="100%"
        height="100%" frameBorder="0"/>

Now when I click the link, it throws:

Uncaught DOMException: Blocked a frame with origin "https://******.my.salesforce.com" from accessing a cross-origin frame.
at Object.handleOnload (https://******/support/console/xdomain/30.0/iframeinterface.js:1:356)
at window.onload (https://******/support/console/xdomain/30.0/crossDomainProxy.html:4:89)

and does not open anything in subtab.

UPDATE

I suspect the reason could be that my console app is opened in lightning experience, thus the url in address bar has lightning in it, where as window.location.href still gives me base url of my org, so it may be a same origin policy, but still dont know how to resolve it.

Javascript on VF page:

    function openInSubtab(asd, asdf) {
            sforce.console.getEnclosingPrimaryTabId(function (r) {
                callBackopenTab(r, asd, asdf);
            });
    }

    function callBackopenTab(r, asd, asdf) {
        console.log('rId : ' + r.id);
        console.log('asd: ' + asd);
        console.log('asdf: ' + asdf);
        sforce.console.openSubtab(r.id, '/' + asd, true, asdf, null);
    }

VF page link:

<a href="javascript:void(0);"openInSubtab('{!asd', '{!asdf');return false;">{!asd}</a>

This works fine when its a VF page and we include this into a flexipage. Now I have embedded this VF page in a lightning component via an iframe.

<iframe id="componentName" src="/apex/VFPAGENAME" width="100%"
        height="100%" frameBorder="0"/>

Now when I click the link, it throws:

Uncaught DOMException: Blocked a frame with origin "https://******.my.salesforce.com" from accessing a cross-origin frame.
at Object.handleOnload (https://******/support/console/xdomain/30.0/iframeinterface.js:1:356)
at window.onload (https://******/support/console/xdomain/30.0/crossDomainProxy.html:4:89)

and does not open anything in subtab.

Javascript on VF page:

    function openInSubtab(asd, asdf) {
            sforce.console.getEnclosingPrimaryTabId(function (r) {
                callBackopenTab(r, asd, asdf);
            });
    }

    function callBackopenTab(r, asd, asdf) {
        console.log('rId : ' + r.id);
        console.log('asd: ' + asd);
        console.log('asdf: ' + asdf);
        sforce.console.openSubtab(r.id, '/' + asd, true, asdf, null);
    }

VF page link:

<a href="javascript:void(0);"openInSubtab('{!asd', '{!asdf');return false;">{!asd}</a>

This works fine when its a VF page and we include this into a flexipage. Now I have embedded this VF page in a lightning component via an iframe.

<iframe id="componentName" src="/apex/VFPAGENAME" width="100%"
        height="100%" frameBorder="0"/>

Now when I click the link, it throws:

Uncaught DOMException: Blocked a frame with origin "https://******.my.salesforce.com" from accessing a cross-origin frame.
at Object.handleOnload (https://******/support/console/xdomain/30.0/iframeinterface.js:1:356)
at window.onload (https://******/support/console/xdomain/30.0/crossDomainProxy.html:4:89)

and does not open anything in subtab.

UPDATE

I suspect the reason could be that my console app is opened in lightning experience, thus the url in address bar has lightning in it, where as window.location.href still gives me base url of my org, so it may be a same origin policy, but still dont know how to resolve it.

Notice added Canonical answer required by Nagendra K S
Bounty Started worth 50 reputation by Nagendra K S
Source Link
Nagendra K S
  • 385
  • 1
  • 6
  • 20

OpenSubtab throws error when embedding a VF page in lightning component

Javascript on VF page:

    function openInSubtab(asd, asdf) {
            sforce.console.getEnclosingPrimaryTabId(function (r) {
                callBackopenTab(r, asd, asdf);
            });
    }

    function callBackopenTab(r, asd, asdf) {
        console.log('rId : ' + r.id);
        console.log('asd: ' + asd);
        console.log('asdf: ' + asdf);
        sforce.console.openSubtab(r.id, '/' + asd, true, asdf, null);
    }

VF page link:

<a href="javascript:void(0);"openInSubtab('{!asd', '{!asdf');return false;">{!asd}</a>

This works fine when its a VF page and we include this into a flexipage. Now I have embedded this VF page in a lightning component via an iframe.

<iframe id="componentName" src="/apex/VFPAGENAME" width="100%"
        height="100%" frameBorder="0"/>

Now when I click the link, it throws:

Uncaught DOMException: Blocked a frame with origin "https://******.my.salesforce.com" from accessing a cross-origin frame.
at Object.handleOnload (https://******/support/console/xdomain/30.0/iframeinterface.js:1:356)
at window.onload (https://******/support/console/xdomain/30.0/crossDomainProxy.html:4:89)

and does not open anything in subtab.