1

I have an <iframe> tag.

I don't know how to add content to that <iframe>

example:---

<iframe id="iframe" src="https://musafiroon.github.io/stackoverflow/index.html" width="200"/>

at https://musafiroon.github.io/stackoverflow I have made 3 elements with attribute class="text"

I want to color all these text blue in my Iframe.

how should I do this?

I am working on my pc with some HTML files inside a folder

Musafiroon
  • 623
  • 6
  • 20
  • 1
    Does this answer your question? [Using CSS to affect div style inside iframe](https://stackoverflow.com/questions/583753/using-css-to-affect-div-style-inside-iframe) or [Edit for iframe contents](https://stackoverflow.com/questions/6834014/edit-for-iframe-contents) – Dan Macak Jul 03 '21 at 07:50

3 Answers3

0

You can't edit the content of an iframe tag.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
0

Does the iframe src url belong to the same origin as the main page? Are they accessed by the same domain name?

If the main page and the iframe content share an origin

Javascript and same origin iframes

Otherwise

You'll need to change something so they share an origin. You can put the iframe content behind a proxy so it shares the main page's origin. If your main page is a dynamic site, you can add a new endpoint (e.g. /iframe), and in the request handler (on the server side) you request your iframe content and return it. Alternatively, you can use a CDN service like AWS CloudFront or Akamai to combine the main page and the iframe content domains into a single domain. You would configure it so that requests to /iframe/* are served by your-iframe-content.com/*, and all other requests are served by your main content server. Explanation for CloudFront

alexanderbird
  • 3,847
  • 1
  • 26
  • 35
0

I feel you can change color of the content in the iframe by defining color of the class--text in the source file "index.html". You can set the color of the content in iframe as per below code..

<style>
.text{
    color:blue;
}
</style>

with your main code.