最近评论
正在载入评论列表...
![]() |
【实例描述】
iframe框架用来加载页面。本例将学习如何动态添加iframe到页面中。
【实现代码】
<html>
<head>
<title> 动态添加框架 </title>
<script language="JavaScript">
window.onload = function()
{
var iframe = document.createElement('iframe'); //动态创建框架
iframe.src="http://www.google.com"; //框架中加载的页面
document.body.appendChild(iframe); //将框架添加到当前窗体
}
</script>
</head>
<body>
</body>
</html>
【难点剖析】
本例的重点是DOM方法的运用。“createElement”方法用来在页面中创建元素,“appendChild”方法用来将元素添加到网页中。