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

  • Home
  • SEARCH
  • 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 8574537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:29:47+00:00 2026-06-11T19:29:47+00:00

I can’t overcome this issue. Can someone give some advice? I have this application

  • 0

I can’t overcome this issue. Can someone give some advice?

  1. I have this application that uses ExtJS library that I will need to run in Chrome extension. I have successfully created my messaging bridge (postMessage), and sandboxed the whole application in it, and everything works as usual. ExtJS loaded, application is running.

  2. Then I have this piece of logic where I need to preview a piece of HTML snippets in my ExtJS viewport. I created an iframe in the Panel itself and on afterrender I tried to write the snippet in it. This is the code I use:

    html: '<iframe src="about:blank" style="width:100%;height:100%;border:none;"></iframe>';
    
    ......
    
    //p is the panel found in afterrender
    p.body.down('iframe').dom.contentDocument.write(content);
    

    Then the error:

    Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL chrome-extension://fcnpmlgapilgclcelfanblpbglmkghbc/core/themes/default/app.html. Domains, protocols and ports must match.

  3. I have tried with postMessage within sandbox to this dynamic iframe but nothing happens. Setting the sandbox attribute in manifest doesn’t work either. This is the only way and it works. See my answer below.

Question:

  1. How should one set the manifest to support this kind of use case?
  2. Or is there any better way to preview HTML snippet without using an iframe? Afaik previewing with iframe is the best as it sandboxed the snippet without being messed with parent css.

Note

This piece of code was working fine in manifest v1 but I planned to migrate it to manifest v2. I didn’t realize Content Security Policy (CSP) has became that strict.

A screen to describe the problem 😉

screen

  • 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-11T19:29:48+00:00Added an answer on June 11, 2026 at 7:29 pm

    Sorry, this is awkward. Apparently postMessage is the only way, and I can’t manage to get it work previously because my iframe is not loaded yet. Also, accessing the dom document in the iframe is a big no under CSP, but it’s possible to access contentWindow to do a postMessage.

    This is what I did to solve this issue. Hope someone would benefit from this:

    1. Create a preview.html in your extension root

    2. Under manifest.json, add it as part of the sandbox attribute

    3. Inside the preview.html, add the following code. Note that my snippet is a full html, so I used document.write instead.

      <!DOCTYPE html>
      <html>
          <head>
              <script>
              window.addEventListener("message", function(e) {
                  if (e.data.content) {
                      document.write(e.data.content);
                  }
              });
              </script>
          </head>
          <body></body>
      </html>
      
    4. Create the iframe in your code as usual, point it to your preview.html, and attach it to the parent div or Ext.Panel.

    5. Use the following code to postMessage after the element has been drawn/created/appended.

      var content = '<!DOCTYPE html><html><body>Hello World!</body></html>';
      var iframe = p.body.down('iframe').dom; //or the iframe node
      
      iframe.onload = function() {
          iframe.contentWindow.postMessage({content: content}, '*');
      };
      

    Enjoy 😉

    Edit

    As pointed by Mike in Chromium forum, this issue can be solved by srcdoc as well. Simply set the iframe’s srcdoc and problem is solved.

    Just not sure of the status of srcdoc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can someone explain why the compiler accepts only this code template<typename L, size_t offset,
Can't figure out how to do this in a pretty way : I have
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
Can someone help me with this scenario? *There is a button, which when tapped,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Can somebody give me advice on how to create a recursive version of GetEnumerator()?
Can someone explain some behaviour I'm seeing in SQL Server 2005? I've been tasked
Can find why i get this error can someone help? package Android.data; public class
can someone tell me why sed won't remove my NULLs? this is on OS
Can anyone give me some tips on adding a custom button for each row

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.