-------------------------------------------------- -------------------
注:页面上元素name属性以及JavaScript引用的名称必须一致包括大小写
否则会提示你1个错误信息 "引用的元素为空或者不是对象"
-------------------------------------------------- -------------------
对象属性
window //窗户自身
window.self //引用本窗户window=window.self
window.name //为窗户命名
window.defaultStatus //设定窗户状态栏信息
window.location //URL地址,配备布置这个属性可以打开新的页面
-------------------------------------------------- -------------------
对象方法
window.alert("text") //提示信息会话框
window.confirm("text") //确认会话框
window.prompt("text") //要求键盘输入会话框
window.setIntervel("action",time) //每一隔指定的时间(毫秒)就执行一次操作
window.clearInterval() //清除时间配备布置作用就是终止轮回
window.setTimeout(action,time) //隔了指定的时间(毫秒)执行一次操作
window.open() //打开新的窗户
window.close() //关闭窗户
-------------------------------------------------- -------------------
成员对象
window.event
window.document //见document对象详解
window.history
window.screen
window.navigator
window.external
-------------------------------------------------- -------------------
window.history对象
window.history.length //浏览过的页面数
history.back() //撤退退却
history.forward() //进步
history.go(i) //到汗青详细登记单的第i位
//i>0进步,i<0撤退退却
-------------------------------------------------- -------------------
window.screen对象
window.screen.width //屏幕宽度
window.screen.height //屏幕高度
window.screen.colorDepth //屏幕色深
window.screen.availWidth //可用宽度
window.screen.availHeight //可用高度(除去任务栏的高度)
-------------------------------------------------- -------------------
window.external对象
window.external.AddFavorite("地址","标题" ) //把网站新增到保藏夹
-------------------------------------------------- -------------------
window.navigator对象
window.navigator.appCodeName //浏览器代码名
window.navigator.appName //浏览器步伐名
window.navigator.appMinorVersion //浏览器补钉版本
window.navigator.cpuClass //cpu类型 x86
window.navigator.platform //操作体系类型 win32
window.navigator.plugins
window.navigator.opsProfile
window.navigator.userProfile
window.navigator.systemLanguage //客户体系语言 zh-cn简体中文
window.navigator.userLanguage //用户语言,同上
window.navigator.appVersion //浏览器版本(包括 体系版本)
window.navigator.userAgent
window.navigator.onLine //用户否在线
window.navigator.cookieEnabled //浏览器是否撑持cookie
window.navigator.mimeTypes
-------------------------------------------------- -------------------
<html>
<!--window对象方法举出例子脚本-->
<script language="javascript">
window.alert("您好!")
</script>
<script language="javascript">
var action
action=window.confirm("请选择操作...")
if(action)
document.write("您选择了接续操作")
else
document.write("您选择了勾销操作")
</script>
<script language="javascript">
var info
info=window.prompt("请输入一些必要的信息")
document.write (info)
</script>
<script language="javascript">
var i;i=0;
function action(){
i++;
window.alert(i) //监督轮回情况
if(i>=10)
window.clearInterval(stop) //终止轮回
}
stop=window.setInterval("action()",1000)//1000毫秒=1秒
</script>
<script language="javascript">
var i;i=0;
function action(){
i++;
window.alert(i) //监督轮回情况
}
window.setTimeout("action()",1000)
//不异的代码setTimeout只执行一次
</script>
</html>
例子1: setInterval:每一经过指定毫秒值后计算1个抒发式 iTimerID = window.setInterval(vCode,iMilliSeconds[,sLanguage]) setTimeout:经过指定毫秒值后计算1个抒发式 TimerID = window.setTimeout(vCode,iMilliSeconds[,sLanguage]) 1个简略例子:2秒钟弹出1个窗户之后2秒钟后封闭:
<script language="javascript">
var b;
function test(){
b=window.open('''','''','''');
window.setTimeout(aa,2000);
}
function aa(){
b.close();
}
window.setInterval(test,2000);
</script>
例子2:
⑴index.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>window举出例子</title>
</head>
<script language="javascript">
<!--
//打开标准样式窗户
function open1(){
//配备布置标准样式窗户的一些状态值
var windowStatus = "dialogWidth:260px;dialogHeight:180px;center:1;sta tus:0;";
//在标准样式窗户中打开的页面
var url = "test.html";
//将标准样式窗户返回的值临时生存
var temp = showModalDialog(url,"",windowStatus);
//将刚才生存的值赋给文本输入框returnValue
document.all.returnValue.value = temp;
}
//打开无菜单窗户
function open2(){
//配备布置窗户的一些状态值
var windowStatus = "left=380,top=200,width=260,height=200,resizable=0 ,scrollbars=0,menubar=no,status=0";
//在窗户中打开的页面
var url = "test1.html";
window.open(url,"noMenuWindowName",windowStatus);
}
//打开全屏窗户
function open3(){
//配备布置窗户的一些状态值
var windowStatus = "fullscreen = 1";
//在窗户中打开的页面
var url = "test2.html";
window.open(url,"noMenuWindowName",windowStatus);
}
-->
</script>
<body>
<input type="button" name="btn1" value="打开标准样式窗户" onClick="open1()">
<br>
从标准样式窗户返回的值:
<input type="text" id="returnValue" name="returnValue">
<br><br>
<input type="button" name="btn2" value="打开无菜单窗户" onClick="open2()">
<br><br>
<input type="button" name="btn3" value="打开全屏窗户" onClick="open3()">
<br><br>
</body>
</html>
⑵test.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>在标准样式窗户中打开的页面</title>
</head>
<script language="javascript">
<!--
//将选中的值师长教师存到隐含对象上
function ok(tempValue){
document.all.selectedValue.value = tempValue;
}
//封闭页面时将隐含对象中的值传回
function willReturnValue(){
window.returnValue = document.all.selectedValue.value;
window.关了();
}
-->
</script>
<body onUnload="willReturnValue()" bgcolor="#D4D0C8">
<center>
请单选您的爱好:
<br>
<br>
<input type="radio" name="lover" value="体育" onClick="ok(this.value)">体育
<br>
<input type="radio" name="lover" value="休闲文娱" onClick="ok(this.value)">休闲文娱
<br>
<input type="radio" name="lover" value="看书读报" onClick="ok(this.value)">看书读报
<br>
(3)test1.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>在无菜单窗户中打开的页面</title>
</head>
<body bgcolor="#D4D0C8">
<center>
请单选您的爱好:
<br>
<br>
<input type="radio" name="lover" value="体育">体育
<br>
<input type="radio" name="lover" value="休闲文娱">休闲文娱
<br>
<input type="radio" name="lover" value="看书读报">看书读报
<br>
<input type="radio" name="lover" value="琴棋字画">琴棋字画
</center>
</body>
</html>
⑷test2.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>在全屏窗户中打开的页面</title>
</head>
<body bgcolor="#D4D0C8">
<center>
请单选您的爱好:
<br>
<br>
<input type="radio" name="lover" value="体育">体育
<br>
<input type="radio" name="lover" value="休闲文娱">休闲文娱
<br>
<input type="radio" name="lover" value="看书读报">看书读报
<br>
<input type="radio" name="lover" value="琴棋字画">琴棋字画
<br>
<br>
<input type="button" name="btn1" value="封闭" onClick="window.关了()">
</center>
</body>
</html>
<input type="radio" name="lover" value="琴棋字画" onClick="ok(this.value)">琴棋字画
<input type="hidden" id="selectedValue" name="selectedValue">
</center>
</body>
</html>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。