?
Solved

assiging quoted html to a frame

Posted on 2005-03-07
5
Medium Priority
?
177 Views
Last Modified: 2010-04-06
is there any way of assigning quoted html rather than a link to an external document, to a frame or iframe?
0
Comment
Question by:ziche
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 13484135
You could use javascript to read the html and create a new document. However due to nowadays cross site scripting protection, this only works when all happens at the same domain/webspace.

Using javascript you would be able to open a document, write content in it, and close it.

From bare head, it should be something like:

<script type="text/javascript">
function newDocWithHTML(frame, html)
{
      f = document.frames[frame];
      f.document.open();
      f.document.write(html);
      f.document.close();
}
</script>

<div id="mysourcehtml">
  bla <b>bla</b> bla
</div>
<button onclick="newDocWithHTML('myiframe', document.getElementById('mysourcehtml').innerHTML);">Test</button>

<iframe name="myiframe"></iframe>
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 200 total points
ID: 13487608
It is no where near that difficult.  Just use about:blank as the original source of an iframe and then write into the body of the page:

<html>
<head>
<script type="text/javascript">
function loadIF()
{
   top.frames['IF'].document.body.innerHTML='<h1>Hello world</h1>';
}
</script>
</head>
<body>
<input type="button" value="Load Iframe" onclick="loadIF()">
<br />
<br />
<iframe name="IF" src="about:blank" height="200px" width="300px"></iframe>
</body>
</html>

Cd&
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 13487713
Would about:blank be supported by NS/others?

-r-
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13488501
I tested it in IE6 and Firefox.  No reason it should not work on any browser that supports iframe.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13495639
Glad we could help. Thanks for the A. :^)

Cd&
0

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question