javascript中实现动态广告的方法 -凯发k8网页登录

开发出高质量的系统

常用链接

统计

积分与排名

好友之家

最新评论

javascript中实现动态广告的方法

以前写的demo继续发
动态广告
有三种实现方法
1,通过js的色settimeout()
    优点: 兼容大多数   doctype 声明
    缺点: 会有延迟的效果。。。。
 
2,通过body 的 onscroll 事件 相应调整
    优点:延迟相对较小
   缺点 :不兼容doctype 
2005
 
3,通过css控制
    优点:无延迟
    缺点:不同浏览器不同,但可以通过方法兼容
例子:
1

<script language="jscript" >
 
function initad() {
  document.all.adlayer.style.visibility 
= 'visible'
  movelayer('adlayer');
 }

 
function movelayer(layername) {
  
var x = 600;
  
var y = 300;
  
var y = document.body.scrolltop20
  eval(
"document.all."  layername  ".style.postop = y");
  eval(
"document.all."  layername  ".style.posleft = x");
  settimeout(
"movelayer('adlayer');"5);
 }

 window.onload
=initad;
script>
<div id=adlayer style='position:absolute; width:61px; height:59px; z-index:20; visibility:hidden;; left: 600px; top: 300px'>
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<br>
 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
<br>
 ccccccccccccccccccccccccccccccccc
<br>
div>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
例子:
2
<html>
<head>
head>
<script language="jscript" >
 
function movelayer() {
  document.all.adlayer.style.postop
=document.body.scrolltop20
  document.all.adlayer.style.posleft
=300;
 }

script>
<div id=adlayer style='position:absolute; width:61px; height:59px; z-index:20; visibility:visible; left: 600px; top: 300px'>
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<br>
 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
<br>
 ccccccccccccccccccccccccccccccccc
<br>
div>
<body id="body" name="body" onscroll = "movelayer()">
 
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
sss
<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>sss<br>
body>
html>
 
例子三
doctype html public "-//w3c//dtd xhtml 1.1//en"  "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<style type="text/css">
body 
{
    margin:
0;  
    border:
0
    height:
100%
    overflow
-y:auto;
    }

#menu 
{display:block; top:10px; left:150px; width:130px; position:fixed;}  
* html #menu {position:absolute;} 
 
style>

head>
 
<body>
<div>
<ul style="list-style-type:decimal">
<li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li>
<li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li><li>li>
<ul>
div>
<div id="menu">
<img src="http://www.cnblogs.com/images/cnblogs_com/goodspeed/795/o_o_mylogo.gif" />
div>
body>
html>
 

posted on 2007-09-10 15:31 dreamstone 阅读(1662) 评论(0)  编辑  收藏 所属分类: 片段脚本语言javascript

网站地图