• --:)欢迎访问锋网源码(:--
  • 首页
  • RSS订阅
  • 常用软件
  • 网页模板
  • 网站运作
  • 锋网学院
  • 繁體中文

  • 学院首页
  • 新闻资讯
  • 网站运营
  • 网站开发
  • 美工设计
  • 数据库类
  • 服务器类
  • 网络应用
  • 操作系统
  • 软件教学
编程开发   认证考试   网络安全   文章搜索: 高级搜索
会员登录/控制面版 您的位置: 学院首页 >> 网站开发 >> JavaScript >> 文章内容
 

精彩推荐

 
 

本类推荐文章

 
 

本类阅读排行

  • 如何打开IE/Firefox的JavaSc..
  • 学习Ajax教程,详细了解Get与..
  • ajax中文乱码解决方法
  • javascript操作select相关方..
  • JS获取各种浏览器窗口的大小
  • 在网页中控制wmplayer播放器
  • 用js写的一个跑马灯
  • 理解JavaScript函数
  • 网页常用特效整理:初级篇
  • 用js实现select对div的隐藏与..
  • 关于Ajax responseText 的一..
  • 网页图片特效小技巧
  • 网页常用特效整理:高级篇
  • JavaScript教程:onmouseover..
  • 利用JAVASCRIPT让IFRAME框架..
  • 网页常用特效整理:中级篇
  • Javascript 编程规范
  • 用javascript实现随机跳转页..
  • 对JavaScript的eval()中使用..
  • AS常用代码集锦
 
 

JavaScript学习笔记 3-框架

  • 日期:2008-10-08     人气:     出处:     作者:
  • 字体大小:
  • 小
  • 中
  • 大

先回顾在html中是如何使用框架的:
Code
<html>
<frameset cols="66%,34%">
<frame src="chicken.html" name="chicken">
<frameset rows="100,*">
<frame src="pastasalad.html" name="pastasalad">
<frame src="jellocubes.html" name="jellocubes">
</frameset>
</frameset>
</html>现在就来看在框架中运用JavaScript的例子:
Code
<html>
<frameset rows="25%,*">
<frame src="frames_example_controls.html" name="control_fram" >
<frame src="blank.html" name="target_frame" >
</frameset>
</html>里面有两个页面,一个是frames_example_controls.html,一个是blank.html:
frames_example_controls.html
<html>
</head>
<body>
<a href="#" onClick="top.target_frame.document.writeln('Monkey do!<br>');">Monkey see</a>
</body>
</html>
top.target_frame.document.writeln("Monkey do!")这句中的 top 是系统内置的变量,翻译的不好,还是看原文:This will always refer to the top-most browser window. If you want to start at the top of the window hierarchy, use top.


最后是一个练习,它涉及到前面学到的内容。

答案如下:


frame代码
<html>
<head>
<title>day_3_homework</title>
</head>
<frameset rows="40%,*" frameborder="1px" border="1px" scrolling="no">
<frame src="day_3_homework_control.html" name="control_frame">
<frame src="day_3_homework_default.html" name="show_frame">
</frameset>
</html>
这个没什么可说的,里而有一点,就是怎么取消框架分隔线

上面的frame取名为control_frame,其代码是:


Code
<html>
<head>
<title>day_3_homework_control</title>
</head>

<body>
<a href="day_3_homework_default.html" target="show_frame"><img src="image/home.gif"></a>
<a href="#"onClick="parent.show_frame.document.bgColor='#00FF00';"><imgsrc="image/green.gif"></a>
<a href="#" onClick="parent.show_frame.document.bgColor='yellow';"><img src="image/yellow.gif"></a>
<a href="day_3_homework_brandme.html" target="show_frame"><img src="image/monkey.gif" name="brandme_img"></a>
</body>

</html>
这段代码里有两个学习点:

下面的frame的内容将有两个页面载入,通过点分别点击control_frame内的两个小图,而显示,其代码分别为:


show_frame内的两个页面的代码
默认页面的代码是:
<html>
<head>
<title>day_3_homework_default</title>
</head>
<body>
<h1>Your Homework Assignment</h1>
<p>Make this page work. If you click on the monkey in the right corner of the page, you'll go to the branding
page from last lesson's homework. If you hit the Home button, you'll come back here. The yellow and green
buttons change the background color of this page.<br><br>
Get these buttons to work, and then View Source to see what I did. </p>
</body>
</html>

-----------------
另一页面的代码是:
<html>
<head>
<title>day_3_homework_brandme</title>
<script language="javascript">
<!--
var image1="image/monkey.gif";
var image2="image/thau.gif";
var image3="image/sun.gif";
-->
</script>
</head>

<body>
<h1>Browser Configuration</h1>
<p>Brand your browser by moving your mouse over the image below until you find one you like. Then click on
the image.</p>
<a href="#" onMouseOver="temp=image1;image1=image2;image2=image3;image3=temp;
window.document.the_image.src=image1;"
onclick="parent.control_frame.document.brandme_img.src=image1;">
<img src="image/monkey.gif" name="the_image" border="0"></a>
</body>
</html>
上面的代码里有很多学习点,值得认真琢磨

相关文章
  • JavaScript学习笔记 4-循环 Loops
  • JavaScript学习笔记 2-变量、字符串
  • JavaScript学习笔记 1-入门
相关软件

  • 网友评论:
  • 查看所有评论
  • 我要发表评论
 

关于本站 | 广告联系 | 版权声明 | 网站地图 | 加入收藏 | 帮助中心 |

Copyright © 2006-2007 fwvv.net  程序支持:木翼  皖ICP备06004916号