|
对框架引用主要有两种方式,一种是通过框架名,一种是通过 frames[] 数组。
通过框架名:
<html>
<head>
<title>通过框架名引用框架</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<iframe name="Frame1" width="300" height="200"> </iframe> <br><br>
<iframe name="Frame2" width="300" height="200"> </iframe> <br><br>
<script type="text/javascript" language="javascript">
<!--
window.Frame1.document.write("欢迎访问");
window.Frame2.document.write("www.groad.net");
-->
</script>
</body>
</html>
输出效果:
通过 frames[] 数组的方式:
<html>
<head>
<title>frames[] 数组引用框架</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<iframe name="Frame1" width="300" height="200"> </iframe> <br><br>
<iframe name="Frame2" width="300" height="200"> </iframe> <br><br>
<iframe name="Frame3" width="300" height="200"> </iframe> <br><br>
<iframe name="Frame4" width="300" height="200"> </iframe> <br><br>
<script type="text/javascript" language="javascript">
<!--
for (var i = 0; i < window.frames.length; i++)
window.frames[i].document.write("第", i+1, "个框架的内容");
-->
</script>
</body>
</html>
效果:
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|