Mori
1
Hi,
I wonder if the following is coded correctly:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
</head>
<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>
</html>
Many thanks in advance!
Mike
pablogo
2
It should work, but, instead of <\/iframe> it should be </iframe>.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
</head>
<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>
</html>
By the way, innerHTML is a De facto standard it will be better to use more standard methods like “createElement”, “appendChild” and so on…
See you
Mori
3
Thanks for the answer, but that way your code doesn’t pass HTML validation.
pablogo
4
I did not notice the DOCTYPE declaration. I thought that the <\TAGNAME> where only for self-closing tags.
See you