Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7902869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:36:59+00:00 2026-06-03T09:36:59+00:00

The HTML parent window and iFrame content know about each other and communicate freely

  • 0

The HTML parent window and iFrame content know about each other and communicate freely when they live on the same web server. When they are saved to DVD, Chrome throws an “Unsafe JavaScript attempt to access frame with URL” when iFrame tries to contact top as a local file.

The catch below catches the permission error, but the error is still registered by the browser and visible to the user.

Is it possible to test first if this access is allowed before attempting to access to preclude the unsafe JavaScript error?

           // Called from script in an iframe
           function findSiblingIFrame(sibId) {
                 try {
                       var sibFrame = top.document.getElementById(sibId);
                       if (sibFrame != null) {
                           alert("found sibling iframe");
                       } else {
                           alert("did not find sibling iframe");
                       }
                   }
                   catch (err) {
                      alert("not allowed to find sibling iframe");
                      // Would rather test if permission first to prevent
                      // browser from registering the error.
                   }
           }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:37:00+00:00Added an answer on June 3, 2026 at 9:37 am

    I ended up using HTML5 messaging to pass potential sandboxed requests up and down the iframe hierarchy.

    For example, each html page in a nested iframe hierarchy has access to the following javascript. If the caught HTML5 message request cannot be executed locally, the message is passed up to the parent. The parent can also pass messages down to iframes. This only works because all the pages have access to the same javascript file.

    // function to handle message request
    function messageHandler(argJSON) {
        // A collection of available functions for inbound messages
        var msgFunctionMap = new Object();
        msgFunctionMap.removeBorder = removeBorder;
        msgFunctionMap.restoreBorder = restoreBorder;
        // ...more
        // try execute request
        try {
            var jsonObj = JSON.parse(argJSON.data);
            msgFunctionMap[jsonObj.request](jsonObj.args);
        }
        catch (err) {
            alert(" Request not supported: " + argJSON.data);
        }
    };
    // example function to remove object id x's border if it exists in "this" window, else pass request up
    var removeBorder = function (jsonMsg, argObj) {
        var xiFrame = document.getElementById("x");
        if (xiFrame != null) {
            xiOrigWidth = xiFrame.style.borderWidth;
            xiFrame.style.borderWidth = '0px';
        }
        // Otherwise, pass message up else if (window.parent && window.parent.postMessage) {
            window.parent.postMessage(jsonMsg.data, "*");
        }
    };
    //... more
    // pass predefined message request from child to parent
    function messageUpHandler(message) {
        if (window.parent && window.parent.postMessage) {
            window.parent.postMessage(message.data, "*");
        }
    };
    // Listener for child messages
    if (window.addEventListener) {
        window.addEventListener("message", messageUpHandler, true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i know i can have iframe in a html page, say parent.htm, and i
I want to pass a variable in my parent window to an iframe html
I have a XUL file with iframe: <window> <iframe src=chrome://plugin/content/options.html style=width: 290px; height: 320px;
I need to resize cross domain iframe to fit content . So in parent.html
popup.html is popped up by script from parent.html: window.open('popup.html', '', 'width=520, height=300,left=500,top=0'); Is it
I know that I cannot style the content of an iFrame loaded from another
When using javascript:parent.location.href in an IFrame to change the parent window, IE briefly changes
In parent.html I set an iframe with child.html in it. in child frame,I write
I have a page in html (parent page) that have inside an iframe. When
I have a parent window with the URL: http://example.com?val=test In the iframe of that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.