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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:14:51+00:00 2026-05-22T15:14:51+00:00

This standard code for an IFRAME, is there a way to replace the src

  • 0

This standard code for an IFRAME, is there a way to replace the src URL with Just html code? so my problem is simple, I have a page it loads an HTML body from MYSQL I want to present that code in a frame so it renders it self independent of the rest of the page and in the confines of that specific bordering.

<iframe src="http://example.com" name="test" height="120" width="600">You need a Frames Capable browser to view this content.</iframe>   
  • 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-22T15:14:52+00:00Added an answer on May 22, 2026 at 3:14 pm

    You can do this with a data URL. This includes the entire document in a single string of HTML. For example, the following HTML:

    <html><body>foo</body></html>
    

    can be encoded as this:

    data:text/html;charset=utf-8,%3Chtml%3E%3Cbody%3Efoo%3C/body%3E%3C/html%3E
    

    and then set as the src attribute of the iframe. Example.


    Edit: The other alternative is to do this with Javascript. This is almost certainly the technique I’d choose. You can’t guarantee how long a data URL the browser will accept. The Javascript technique would look something like this:

    var iframe = document.getElementById('foo'),
        iframedoc = iframe.contentDocument || iframe.contentWindow.document;
    
    iframedoc.body.innerHTML = 'Hello world';
    

    Example


    Edit 2 (December 2017): use the Html5’s srcdoc attribute, just like in Saurabh Chandra Patel‘s answer, who now should be the accepted answer! If you can detect IE/Edge efficiently, a tip is to use srcdoc-polyfill library only for them and the “pure” srcdoc attribute in all non-IE/Edge browsers (check caniuse.com to be sure).

    <iframe srcdoc="<html><body>Hello, <b>world</b>.</body></html>"></iframe>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our data access layer at work we have this standard implementation where the
I have the VS2005 standard edition and MS says this: Note: The Windows Service
Since I'm sure many people have different standard, I've made this post a community
Ok, I know this is a strange question, but there is a standard (fan-wise
This must be something very simple for the JavaScript experts out there. In the
I have this code guile> (cairo-pdf-surface-create foo.pdf 100.0 100.0) ; and get this error
I was wondering if this is Standard, or a bug in my code. I'm
Can standard pointers in .Net do this? Or does one need to resort to
This is a question regarding Unix shell scripting (any shell), but any other "standard"
I'm looking at this control, and it seems to be lacking the standard .net

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.