javascript基础 BOM 第42天

2012-11-17 10:50:36 0  category: 第二阶段php

事件:

Ondblclick

Onbeforeunload     在退出前执行该方法

Location对象

属性

location.href

方法

location.replace()

location.reload()

注意:replace()方法在地址栏当中不能后退

History历史对象

方法

back()

forward()

go()

frames对象  [分帧对象]

学习分帧重点是按照层次结构找好对象。

学习七种找法。

Window.top.frames[0]

Widnow.top.frames[left]

window.top.frames.t

window.top.frames.item(0)

window.top.frames.item('right')

window.top.t.document

window.top[t]


a.php


<a href="javascript:history.back()">遇到错误</a><br>
<a href="javascript:history.go(-2)">两页前</a>


child.html


<html>

<head>

</head>

<body>
php.xlxz.org。


<button onclick="red()">红</button>
<button onclick="green()">绿</button>
<button onclick="blue()">蓝</button>


<script>
var o=window.opener;

function red(){

o.document.bgColor='red';
}

function green(){

o.document.bgColor='green';
}

function blue(){

o.document.bgColor='blue';
}
</script>
</body>
</html>


client.html


<html>
<head>
</head>
<body onmousemove="show()">
<script>
function show(){
window.status='x'+window.event.clientX+'y'+window.event.clientY;
}
</script>
</body>
</html>


contextmenu.html


<html>
<head>
</head>
<body oncontextmenu="show()">
<script>
function show(){
window.event.returnValue=false;
}
</script>
</body>
</html>


copy.html


<html>
<head>
</head>
<body>
<div id="content">php.xlxz</div>
<button onclick="copy()">复制</button>
<script>
function copy(){
var d=document.getElementById('content').innerHTML;
window.clipboardData.setData('text',d+'美女.http://php.xlxz.org');
}
</script>
</body>
</html>


ctrl.html


<html>
<head>

</head>

<body onkeydown="show()">


<script>
function show(){
if(event.ctrlKey){

alert('aaaaaaaaaaaaaaaa');
}else if(event.shiftKey){
alert('bbbbbbbbbbbbb');

}else if(event.altKey){

alert('ccccccccccccccccccc');
}
/*
if(event.ctrlKey&&(event.keyCode==67)){
alert('本站禁止ctrl+c');
}
*/
}
</script>
</body>
</html>


event.html


<html>
<head>

</head>

<body>
<p onmouseover="show()">www</p>
<p onmouseover="show()">php</p>
<p onmouseover="show()">xlxz</p>
<p onmouseover="show()">org。</p>
<p onmouseover="show()">com</p>
<script>
function show(){
var d=window.event.srcElement;
d.style.background='orange';
}
</script>
</body>
</html>


form.html


<html>
<form action="a.php" method="get">
<input type="text" name="username">
<input type="password" name="password">
<input type="checkbox" name="a">
<input type="checkbox" name="a">
<input type="checkbox" name="a">
<textarea name="haha"></textarea>
<input type="submit" value="提交">
</form>
<a href="javascript:history.forward()">前进</a>
</html>


game.html


<html>
<head>

</head>

<body onkeydown="chan()">
<img src="images/ren_q_1.gif" id="img" style="position:absolute;top:0px;left:0px"/>


<script>
var img1='ren_q_1.gif';
var img2='ren_q_2.gif';
var xs=0;
var ys=0;
var jsq=null;
var flag=false;

xiaoren();

function xiaoren(){
jsq=setInterval(function(){
var img=document.getElementById('img');

var name=parseUrl(img.src);

var x=parseInt(img.style.left);
var y=parseInt(img.style.top);

img.style.left=(x+xs)+'px';
img.style.top=(y+ys)+'px';


if(name==img1){

img.src='images/'+img2;
}else{

img.src='images/'+img1;
}

},100)
}

function chan(){

switch(window.event.keyCode){

case 87:
img1='ren_h_1.gif';
img2='ren_h_2.gif';
ys=-5;
xs=0;
break;
case 83:
img1='ren_q_1.gif';
img2='ren_q_2.gif';
ys=5;
xs=0;
break;
case 65:
img1='ren_l_1.gif';
img2='ren_l_2.gif';
xs=-5;
ys=0;
break;
case 68:
img1='ren_r_1.gif';
img2='ren_r_2.gif';
xs=5;
ys=0;
break;
case 32:
if(!flag){
clearInterval(jsq);
flag=true;
break;
}
case 13:
if(flag){
xiaoren();
flag=false;
}
}
}
function parseUrl(url){
var wz=url.lastIndexOf('/')+1;
var sub=url.substr(wz);
return sub;
}
</script>
</body>
</html>


gd.html


<html>
<head>

</head>

<body ondblclick="show()" onclick="stop()">

<script>
var jsq=null;
function show(){

jsq=setInterval(function(){
scrollBy(0,1);
},500)

}

function stop(){

clearInterval(jsq);
}
</script>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
<p>xlxz</p>
</body>
</html>


keyCode.html


<html>
<head>
</head>
<body onkeydown="show()">
<script>
function show(){
alert(window.event.keyCode);
}
</script>
</body>
</html>


location.html


<html>

<head>

</head>

<body>
<script>


window.location='http://php-php.com';


/*

setInterval(function(){
window.location.reload();
},1000);


var d=new Date();

document.write(d);
window.location.href="http://www.xlxz.org";
window.location.replace('http://php.xlxz.org');
*/
</script>
</body>
</html>


mc.html


<html>
<h1 id="one" onmouseover="start()" onmouseout="stop()" style="text-align:center">0</h1>
<script>
var i=0;
var jsq=null;
function start(){
jsq=setInterval(function(){
i++;
var o=document.getElementById('one');
o.innerHTML=i;
},1000)
}
function stop(){
clearInterval(jsq);
}
</script>
</html>


nav.html


<script>

var str=navigator.appVersion;

var arr=str.split(';');


if(arr[1]==' MSIE 7.0'){

document.write('您的浏览器版本过低,有可能泄露您的个人隐私,我们禁止你访问本站');
}



document.write(navigator.appCodeName+'<br>');
document.write(navigator.appVersion+'<br>');
document.write(navigator.appName+'<br>');
document.write(navigator.language+'<br>');
document.write(navigator.platform+'<br>');
document.write(navigator.userAgent+'<br>');


</script>


oneforeunload.html


<html>
<head>

</head>

<body onbeforeunload="show()">


<script>
function show(){
window.event.returnValue='php.xlxz.org';
}

</script>


</body>

</html>


opener.html


<html>
<head>
</head>
<body>
<button onclick="red()">红</button>
<button onclick="yellow()">灯</button>
<button onclick="qu()">区</button>
<script>
var t=open('child.html','jj','');
function red(){
t.document.bgColor='red';
}
function yellow(){
t.document.bgColor='yellow';
}
function qu(){
t.document.bgColor='pink';
}
</script>
</body>
</html>


pm.html


<script>
document.write(screen.availHeight+'<br>');
document.write(screen.availWidth+'<br>');
document.write(screen.colorDepth+'<br>');
document.write(screen.height+'<br>');
document.write(screen.width+'<br>');
</script>


qxmp.html


<html>
<head>
</head>
<body onclick="alert('aaaaaaaaaaaa')">
<img src="knock.jpg" width="400" onclick="show()" />
<script>
function show(){
alert('bbbbbbbbbbb');
window.event.cancelBubble=true;
}
</script>
</body>
</html>


sc.html


<script>
function show(){
window.external.AddFavorite(window.location.href,'测试');
}
</script>
<a href="javascript:void(0)" onclick="show()">收藏</a>


selector.html


<html>

<head>

</head>

<body>
is php?
<button onclick="tan()">php.xlxz.org</button>
<script>
function tan(){
var t=document.selection.createRange();
alert(t['text']);
}
</script>
</body>
</html>


st.html


<html>

<head>

</head>

<body onclick="show()">

<img src="cls.jpg" style="position:absolute;top:-500px;" id="st" />
<script>
function show(){
var x=window.event.clientX;
var y=window.event.clientY;
var img=document.getElementById('st');
img.style.top=y+'px';
img.style.left=x+'px';
}
</script>
</body>
</html>