|
|
|
³³³学
习 园 地³³³
考试大纲:职高计算机等级考试 |
职高英语等级考试 |
英语考试样题
计算机等级考试8四川
:一级|
二级|
三级
全国
:一级 |一级B|
二级VFP|
二级VB|
三级|
四级
基础篇:微机基础 |
文件管理 |
因特网操作|
电子邮件
|
BBS论坛
|网页基础1
|网页基础2
|
网页基础3
数据库:VFP6_基础|
VFP6_命令|
报表与菜单|
表单设计
|
查询数据
|
编程初步
|
数据网页
|
上机考试
网页篇:网页表单 |
动态网页 |
JAVA脚本1 |JAVA脚本2
|JAVA脚本3
|JAVA脚本4
|JAVA脚本5
|
JAVA脚本6
职称篇:职称计算机等级考试
网络知识部分
操作题解题辅导
JavaScript应用实例
一、 Window对象例子1:打开一个新窗口
当打开这个网页时,利用 onload 事件,将首先自动打开一个窗口,并显示另一个文件box.hml。
<html>
<head>
<script language="JavaScript">
function openWindow(theURL,features)
{ window.open(theURL,"winName",features);}
</script>
</head>
<body onload="openWindow('box.htm','width=550,height=100')">
</body>
</html>
二、 Window对象例子2:打开一个新窗口
当单击超链接时,利用链接指向的函数,将首先自动打开一个窗口,并显示另一个文件box.hml。
<html>
<head>
<script language="JavaScript">
function openWindow2(theURL,widths,heights)
{ window.open(theURL,"winName","width=" & widths & "," & "height=" &
heights);}
</script>
</head>
<body>
<a href="javascript:openWindow2('box.htm','550','300')">单击这打开新窗口</a>
</body>
</html>
三、 Window对象例子3:在一个新窗口中显示内容
打开一个新窗口,该窗口无工具栏,无地址栏,无导航条,无状态栏,无菜单、有滚动条,不能改变大小。窗口宽660,高480。
<html>
<script language="javascript">
function callpage(htmlurl){
var newwin=window.open
(htmlurl,"newWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,
resizable=no,top=2,left=2,width=660,height=480");return false;}
</script>
<body>
<a href="新闻.htm" onClick="return callpage(this.href);">新闻简报</a>
</body>
</html>
四、产生一个新窗口并显示信息
<html>
<head>
<script language="JavaScript">
function WinOpen() {
msg=open("","DisplayWindow","toolbar=no,directories=no,menubar=no");
msg.document.write("<HEAD><TITLE>你好!</TITLE></HEAD>");
msg.document.write("<CENTER><h2>这是JavaScript产生的新窗口!</h2></CENTER>");
}
</script>
</head>
<body>
<form>
<input type="button" name="Button1" value="单击" onclick="WinOpen()">
</form>
</body>
</html>
五、产生随机数
<html>
<head>
<script language="JavaScript">
function RandomNumber() {
today = new Date();
num = Math.abs(Math.sin(today.getTime()));
return num;
}
</script>
</head>
<body>
<script language="JavaScript">
document.write("这是一个随机数:", RandomNumber());
</script>
</body>
</html>
做法是以上一个例中的时间函数,它会产生一个很大的数,利用这个数再做正弦函数(sin) 的运算, 得到的数再做绝对值的运算,结果可以得到一个介于 0 与 1
间的数。(时间的变化单位是毫秒。)
六.onMouseOver、onMouseOut事件例子,当鼠标移动到表格上时,表格背景色改变!
<html>
<body>
<script language="javascript">
function mOvr(obj,clrOver) {
if (!obj.contains(event.fromElement)) {
obj.bgColor = clrOver; }}
function mOut(obj,clrIn) {
if (!obj.contains(event.toElement)) {
obj.bgColor = clrIn; }}
</script>
<p align="center">当鼠标移动到表格上时,表格背景色改变! </p>
<table border="1">
<tr>
<td onmouseout="mOut(this,'#00ffff');"
onmouseover="mOvr(this,'#ff0000');">这是一个表格</td>
</tr>
</table>
</body>
</html>
this是Javascript的一个关键字,代表当前的对象,可以在对象方法中来引用。 |