Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Error with window.top.opener in Unified Client Interface

(0) ShareShare
ReportReport
Posted on by 7,316
Hi,
I have a client side script with window.top.opener line in it. This is where error is being thrown when debugged.
This script was working fine but started throwing this below error today.
Blocked a frame with origin "">http://www.<domain>.com" from accessing a cross-origin frame.

I know using window.top is not supported but it was working fine, so didn't look into it earlier.
Can somebody please let me know what this error means and how to fix it?
Thanks for any help.

  • Suggested answer
    Pankaj Gogoi Profile Picture
    Pankaj Gogoi 3,177 on at
    RE: Error with window.top.opener in Unified Client Interface

    Hello,

    As suggested, you should avoid using the window.top. if you can, let us know what your requirement and we can suggest alternative design approach.

    Here is a link for your reference.

    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/use-iframe-and-web-resource-controls-on-a-form#enabling-iframe-communication-across-domains

    Best Regards

    PG

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 1,014 Super User 2024 Season 2 on at
    RE: Error with window.top.opener in Unified Client Interface

    Hi meenoo,

    window.top is not supported. When used, The following script error will be displayed to users or included in your error logs: Error: Blocked a frame with origin "https://<yourinstance>.dynamics.com" from accessing a cross-origin frame. The error means that you are trying to access a window owned by an application context external to Dynamics 365. Due to the differing origins, the browser presents the user with a cross-origin security error.

    The following are the recommended approaches:

    • Avoid usage of the window.top object altogether.

    • If using window.top is the only available option, first test to determine whether window.top is accessible by using the script below. If it's not available, provide alternate logic or a fallback user experience.

    function isTopAccessible() {
        try {
                window.top.location;
                return true;
            }
            catch (err) {
                return false;
            }
    }
    
    var canAccess = isTopAccessible();
    alert(canAccess);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans