北京和美国时差多少:怎样调用*.JS文件??

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 06:17:56
var delta=0.15
var collection;
function floaters() {
this.items = [];
this.addItem = function(id,x,y,content)
{
document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute; width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');

var newItem = {};
newItem.object = document.getElementById(id);
newItem.x = x;
newItem.y = y;

this.items[this.items.length] = newItem;
}
this.play = function()
{
collection = this.items
setInterval('play()',10);
}
}
function play()
{

for(var i=0;i<collection.length;i++)
{
var followObj = collection[i].object;
var followObj_x = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
var followObj_y = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);

if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {
var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
followObj.style.left=followObj.offsetLeft+dx;
}

if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) {
var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta;
dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
followObj.style.top=followObj.offsetTop+dy;
}
followObj.style.display = '';
}
}

if (window.screen.width>=1024) //当分辨率达到 1024 时才显示广告
{
var theFloaters = new floaters();

theFloaters.addItem('followDiv1','document.body.clientWidth-106',80,'<a href=rq/tiao_ya_xiang/city_regustation.htm target=_blank><img src=images/ad/c02.gif border=0></a><br><br><a href=rq/0730ttnmn.htm target=_blank><img src=images/ad/x02.gif width=100 height=100 border=0></a>');
theFloaters.addItem('followDiv2',6,80,'<a href=lng/lnggongyi3.htm target=_blank><img src=images/ad/c01.gif border=0></a><br><br><a href=regu.html target=_blank><img src=images/ad/x01.gif width=100 height=100 border=0></a>');
theFloaters.play();
}

//-------------------对联广告代码结束----------------------

把这些代码存成.JS的文件,然后需要加对联广告的页里插入,

<script type="text/javascript" language="javascript1.2" src="*.js"></SCRIPT>

就OK啦

对于上面的具体操作是怎么样啊?步骤详细些,我做了后不行啊!!
相对路径跟绝对路径有什么区别?????

先新建一个文本文件,然后改名为test.js,注意后缀名是js,然后把上面的代码拷贝到这个文件中。

在需要加入对联广告的页面加入:

<script type="text/javascript" language="javascript1.2" src="test.js"></SCRIPT>就可以了。

注意这个文件和你引用页面的路径问题,因为这里采用的是相对路径。

<Script language="javascript" url=""></script>

也就是说你的test.js文件要与调用test.js文件的程序文件在同一目录下