您的位置:首页 > Web前端 > JavaScript

JavaScript学习笔记--第五章.其它

2010-07-17 14:15 309 查看
第五章.其它
一. 状态栏
1.按钮调用
<script language="JavaScript">
<!-- Hide
function moveover(txt) {
window.status = txt;
setTimeout("erase()",1000);
}
function erase() {
window.status="";
}
// -->
</script>
参数:
Txt:状态栏欲显示的字符串
函数:
setTimeout: 是当某段设定的时间 "跑" 完了之後,便执行某函式
2.链接调用
<a href="tpage.html" onMouseOver="window.status='Just another stupid link...'; return true">

二.数组(Array)
function initArray() {
this.length = initArray.arguments.length
for (var i = 0; i < this.length; i++)
this[i+1] = initArray.arguments[i]
}
三.前进 后退
1.按钮调用
<INPUT TYPE="button" VALUE="Back" onClick="history.back()">
<INPUT TYPE="button" VALUE="Next" onCLick="history.forward()">
您也可以用 history.go(-1) 和 history.go(1) 代替
2.图片链接
<a href ="" onClick="parent.history.back(); return false;" onMouseOver="self.status='后退' ;return true;">
<img src="back.gif" border=0></a>
<a href ="" onClick="parent.history.forward(); return false;" onMouseOver="self.status='前进'; return true;">
<img src="forward.gif" border=0></a>
四.获得光标
1.函数调用
function setfocus() {
document.first.text1.focus();
return;
}
2.页面载入
<body onLoad="setfocus()">

五.滚屏
<SCRIPT Language="JavaScript">
<!--function scrollit(){
for (I=1; I<=500; I++){
parent.scroll(1,I)
}}
//-->
</SCRIPT>
六.热键
<script language="JavaScript1.2">
var travel=true
var hotkey=104 /*该值为热键的键值*/
var destination="index.htm" /*链接文件名*/
if (document.layers)
document.captureEvents(Event.KEYPRESS)
function backhome(e){
if (document.layers){
if (e.which==hotkey&&travel)
window.location=destination
}
else if (document.all){
if (event.keyCode==hotkey)
window.location=destination
}
}
document.onkeypress=backhome
</script>
七.页面自动刷新
每隔10秒自动刷新一次
<META content="10; URL=js67.htm" http-equiv=Refresh>
八.文件框的使能性(disabled)
<input type="checkbox" name="tp1" value="1" onclick="if(this.checked){txtNo.disabled=false}else{txtNo.disabled=true}">
<input type="text" name="txtNo" size="20" disabled>
九.复选框/单选框
属性就是:被选中 checked==true
第五章.其它
一. 状态栏
1.按钮调用
<script language="JavaScript">
<!-- Hide
function moveover(txt) {
window.status = txt;
setTimeout("erase()",1000);
}
function erase() {
window.status="";
}
// -->
</script>
参数:
Txt:状态栏欲显示的字符串
函数:
setTimeout: 是当某段设定的时间 "跑" 完了之後,便执行某函式
2.链接调用
<a href="tpage.html" onMouseOver="window.status='Just another stupid link...'; return true">

二.数组(Array)
function initArray() {
this.length = initArray.arguments.length
for (var i = 0; i < this.length; i++)
this[i+1] = initArray.arguments[i]
}
三.前进 后退
1.按钮调用
<INPUT TYPE="button" VALUE="Back" onClick="history.back()">
<INPUT TYPE="button" VALUE="Next" onCLick="history.forward()">
您也可以用 history.go(-1) 和 history.go(1) 代替
2.图片链接
<a href ="" onClick="parent.history.back(); return false;" onMouseOver="self.status='后退' ;return true;">
<img src="back.gif" border=0></a>
<a href ="" onClick="parent.history.forward(); return false;" onMouseOver="self.status='前进'; return true;">
<img src="forward.gif" border=0></a>
四.获得光标
1.函数调用
function setfocus() {
document.first.text1.focus();
return;
}
2.页面载入
<body onLoad="setfocus()">

五.滚屏
<SCRIPT Language="JavaScript">
<!--function scrollit(){
for (I=1; I<=500; I++){
parent.scroll(1,I)
}}
//-->
</SCRIPT>
六.热键
<script language="JavaScript1.2">
var travel=true
var hotkey=104 /*该值为热键的键值*/
var destination="index.htm" /*链接文件名*/
if (document.layers)
document.captureEvents(Event.KEYPRESS)
function backhome(e){
if (document.layers){
if (e.which==hotkey&&travel)
window.location=destination
}
else if (document.all){
if (event.keyCode==hotkey)
window.location=destination
}
}
document.onkeypress=backhome
</script>
七.页面自动刷新
每隔10秒自动刷新一次
<META content="10; URL=js67.htm" http-equiv=Refresh>
八.文件框的使能性(disabled)
<input type="checkbox" name="tp1" value="1" onclick="if(this.checked){txtNo.disabled=false}else{txtNo.disabled=true}">
<input type="text" name="txtNo" size="20" disabled>
九.复选框/单选框
属性就是:被选中 checked==true
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: