Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Client-side Scripting _ Write a dynamic iframe

Posted by: RainLover Nov 11 2011, 01:48 PM

Hi,

I wonder if the following is coded correctly:

CODE
<!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

Posted by: Christian J Nov 11 2011, 03:03 PM

Seems correct, but of course it will only work if inline frames and javascript are enabled/supported. At least some search engine's (Google) claim to be able to find the framed page's URL in the script as well, in which case they might link directly to the orphaned page.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)