为你而来

javascript左右两侧广告的滑动特效

 1 <html>
 2 <head>
 3 <title>1</title>
 4 <style type='text/css'>
 5 #divbox{
 6     border:dashed 1px green;
 7     position:absolute;
 8     left:100px;
 9     top:30px;
10     width:100px;
11     height:100px;
12 }
13 </style>
14 </head>
15 <body>
16 <div id='divbox'></div>
17 <script language='javascript'>
18     /*window.onbeforeunload=function(){
19         alert('java web');
20         //return '加入收藏夹';
21     }*/
22     /*window.onresize=function(){
23         var object=document.getElementById('divbox');
24         object.style.width=document.body.clientWidth*0.9+'px';
25         object.style.height=document.body.clientHeight*0.9+'px';        
26     }
27     window.onload=function(){
28         var object=document.getElementById('divbox');
29         object.style.width=document.body.clientWidth*0.9+'px';
30         object.style.height=document.body.clientHeight*0.9+'px';
31     }*/
32     /*window.onscroll=function(){
33         var object=document.getElementById('divbox');
34         object.style.top=30+document.body.scrollTop+'px';
35         object.style.left=100+document.body.scrollLeft+'px';
36     }*/
37     function fun(){
38         var object=document.getElementById('divbox');
39         var t=object.style.top;
40         var l=object.style.left;
41         object.style.top=30+document.body.scrollTop+'px';
42         object.style.left=100+document.body.scrollLeft+'px';
43         with(object.style){
44             if(top!=t || left!=l){
45                 flag=window.setTimeout("fun();",500);
46             }else{
47                 flag=false;
48                 document.title='java web';
49             }
50         }
51         
52     }
53     for(var i=0;i<200;i++){
54         document.write('<br/>');
55     }
56     var flag=window.setTimeout("fun();",500);
57     window.onscroll=function(){
58         if(!flag){
59             flag=window.setTimeout("fun();",500);
60             document.title='java web!!!';
61         }
62     }
63 </script>
64 </body>
65 </html>

 

posted on 2012-06-04 20:30  为你而来  阅读(451)  评论(0编辑  收藏  举报

导航