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 6654809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:26:03+00:00 2026-05-26T01:26:03+00:00

I have a HTML template that I’m rendering using Django. I’m passing in all

  • 0

I have a HTML template that I’m rendering using Django. I’m passing in all the necessary context variables — my_heading is the heading, my_html is the mark-safed html. I’d like to display my_html in the iframe.

<html>
    <head>
        <title>Iframe Example</title>
    </head>
    <body>
        <p>{% my_heading %}</p>
        <iframe name="iframe1" width="600" height="400" src="http://www.yahoo.com" frameborder="yes" scrolling="yes"></iframe>
    </body>
</html> 

Would you know how to do this? All the examples I’ve found show the iframe pointing to a URL. I’m god-horrible at HTML and JS. 😐

Thanks

  • 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-05-26T01:26:04+00:00Added an answer on May 26, 2026 at 1:26 am

    I used this hack to do it. The div is hidden and contains the HTML. The IFrame doesn’t point to a location because I don’t want any CORS issues. I then inject my HTML into it.

    <html>
        <head>
            <title>Iframe Example</title>
        </head>
        <body>
            <p>{% my_heading %}</p>
            <iframe name="iframe2" id="iframe2" width="0" height="0" src="" style="border:0px; overflow-x:hidden;"></iframe>
            <div id="page" style="display:none" >{{ my_html }}</div>
    
            <script type="text/javascript">
    
              function getWindow(iframe) {
                  return (iframe.contentWindow) ? iframe.contentWindow : (iframe.contentDocument.document) ? iframe.contentDocument.document : iframe.contentDocument;
              }
    
              getWindow(document.getElementById('iframe2')).document.open();
                  getWindow(document.getElementById('iframe2')).document.write(document.getElementById('page').innerHTML);
              getWindow(document.getElementById('iframe2')).document.close();
    
              document.getElementById('iframe2').style.height = (getWindow(document.getElementById('iframe2')).document.body.scrollHeight + 20) +"px";
              document.getElementById('iframe2').style.width = (document.getElementById('iframe2').parentNode.offsetWidth) +"px";
    
            </script>
        </body>
    </html> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a function that retrieves a html template, then binds data using
I have a base.html template that contains a list of links. Example: <div id=sidebar1>
Absolute beginner question: I have a template file index.html that looks like this: ...
I have a web application where the masterPage/template contains some static HTML that never
I have simple template that's html mostly and then pulls some stuff out of
hi have a php template that displays an html page. in it there is
I am using underscore.js's templating capabilities from backbone.js, I have the following template that
I have a view template that is currently FooBundle:Bar:baz.html.twig . However, since I have
I have a WordPress template that contains the following element: <html xmlns=http://www.w3.org/1999/xhtml <?php language_attributes('xhtml');
I'm using ColdFusion to populate a template that includes HTML unordered lists ( <ul>

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.