Link to home
Start Free TrialLog in
Avatar of ziche
ziche

asked on

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?
Avatar of Roonaan
Roonaan
Flag of Netherlands image

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>
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Would about:blank be supported by NS/others?

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

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

Cd&