Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

assiging quoted html to a frame

is there any way of assigning quoted html rather than a link to an external document, to a frame or iframe?
0
ziche
Asked:
ziche
  • 3
  • 2
1 Solution
 
RoonaanCommented:
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
 
COBOLdinosaurCommented:
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
 
RoonaanCommented:
Would about:blank be supported by NS/others?

-r-
0
 
COBOLdinosaurCommented:
I tested it in IE6 and Firefox.  No reason it should not work on any browser that supports iframe.

Cd&
0
 
COBOLdinosaurCommented:
Glad we could help. Thanks for the A. :^)

Cd&
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now