It should be:
Code:
<body>
<div id="container"></div>
<script type="text/javascript">
var url = "http://www.example.com/";
var content = "<iframe width='800' height='600' frameborder='0' src=" + url + "><\/iframe>";
document.getElementById("container").innerHTML = content;
</script>
</body>
Apart from that, this is not dynamic coding. It's the same as writing the iframe directly to the page.
If you want to dynamically write the iframe to the page, you would do something like:
Code:
<head>
<script type="text/javascript">
function dynamic_iframe(id,content)
{
document.getElementById(id).innerHTML = "<iframe width='800' height='600' frameborder='0' src=" + content +"><\/iframe>";
}
</script>
</head>
<body>
<a href="javascript: void(0)" onclick="dynamic_iframe('container', 'http://www.example.com')">load</a>
<div id="container"></div>
</body>
Of course, the onclick could be replaced with an onload.
===
Arie Molendijk.
Bookmarks