JavaScript第八讲:Windows对象中的常用对象属性

本节主要讲解Windows对象中的常用对象属性,下面我们用具体实例来做详细说明。

window:

    document

    location 位置 

             <meta http-equiv="refresh" content="3">//3秒钟刷新一次

              <meta http-equiv="refresh" content="3";url="http://www.baidu.com">//3秒钟跳转的baidu.com页面

              header("Location:login.php");php用法,前面不能有输出

              window.navigate(url)

              location.href='url'

              location.replace("url")  

   history

            history.back()和history.go(-1)是等价的

            history.go(-2)

   screen

           

     .......    

    记的:

         location="url"

         location.reload(ture)

 

例1

<html>

<head>

<meta http-equiv="refresh" content="3";url='pop.html'>

</head>

<script>

document.write(new Date()+"<br>");

</script>

</html>

 

例2

<html>

<head>

</head>

<script>

setTimeout(function{

//window.navigate('pop.html');

//window.location.href='pop.html';

//location='pop.html';//推荐使这种方式

location.replace('pop.html');//不能后退,把当前的页面替换成现在的页面

location.reload(true);//刷新

},3000);

document.write(new Date()+"<br>");

</script>

</html>

 

例3

one.html

<a gref="two.html"></a>

 

 

two.html

<a href="three.html">three</a><br>

<a href="javascript:history.back()">返回</a>

 

three.html

<a href="javascript:history.go(-1)">返回上一步</a><br>

<a href="javascript:history.go(-2)">返回上两步</a><br>

 

例4

<script>

with(document){

write("您的屏幕显示设置如下:<p>");

write("屏幕的实际高度为",screen.availHeight,"<br>");

write("屏幕的实际宽度为",screen.availWidth,"<br>");

write("屏幕的色盘深度为",screen.colorDepth,"<br>");

write("屏幕区域的高度为",screen.height,"<br>");

write("屏幕区域的宽度为",screen.width);

}

</script>

 

 

例5  //剪切板

<div  id="one">

aaaaaaaaaaaaaaaaa<br>

aaaaaaaaaaaaaaaaa<br>

</div>

<input type="button" οnclick="copyc()" value="copecode">

<script>

var one=document.getElementById("one");

function copyc(){

var content=one.innerText;

window.clipboardData.setData("Text",content)//剪切板

}

</script>

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值