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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:12:46+00:00 2026-06-11T03:12:46+00:00

In chrome if I have HTML as a string in a var named html

  • 0

In chrome if I have HTML as a string in a var named html I can easily just load it into an iframe and have the iframe execute that html page (with whatever css/jss/etc it might contain) by doing:

window.sHTML = html;
iframe.src = javascript:parent.sHTML

In Firefox this doesn’t work at all. Is there a way to do this that works in firefox? Note that I need the JS to execute properly in the iframe. For example this fiddle http://jsfiddle.net/9k9Pe/2/ kind of does what I want but if there is a script tag inside the html then that breaks things.

UPDATE: This actually does work in firefox, it just interacts differently with window.location which was breaking my code.

  • 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-11T03:12:48+00:00Added an answer on June 11, 2026 at 3:12 am

    Answering my own question:

    window.sHTML = html;
    iframe.src = javascript:parent.sHTML
    

    This actually does work in firefox, it just interacts differently with window.location which was breaking my code.

    To go into more detail, in chrome if you do

    iframe.src = www.foo.com/bar.html
    window.sHTML = html;
    iframe.src = javascript:parent.sHTML
    

    Then the iframe will execute the html in the html string but its window.location will remain http://www.foo.com/bar.html and relative links will be treated as though the iframe were from http://www.foo.com/bar.html

    However in FF the window.location becomes javascript:parent.sHTML and relative links will no longer work the way one expects.

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

Sidebar

Related Questions

I have this string that represents the body of a page, which I would
I have following page <html> <head> <script type=text/javascript src=e01.js></script> </head> <body> <script type=text/javascript> var
I have a Chrome app that opens a popup window. I would like it
Note: I'm using Google Chrome Currently I have this test page http://www.evecakes.com/doodles/canvas_size_issue.htm It should
I have a weird bug in Chrome which affects a page in Wordpress. I
I have the following Javascript and Html code that works fine in an MVC4
I have an HTML template and CSS that renders a textarea field, however when
I have a Ruby hash that contains a user-generated string. I need to pass
I have some javascript that manipulates html based on what the user has selected.
I have this code in an HTML page: alert(JSON.stringify(new Date())); I'm including the latest

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.