网页两侧浮动广告代码
2008-02-23 08:00:12来源:互联网 阅读 ()
"< DIV id=floater1 style="Z-INDEX: 100; LEFT: 10px; VISIBILITY: visible; WIDTH: 100px; POSITION: absolute; TOP: 160px; height: 100px;" >
左邊的東西,可以是圖片,表格
< /DIV >
< DIV id=floater style="Z-INDEX: 100; RIGHT: 10px; VISIBILITY: visible; WIDTH: 100px; POSITION: absolute; TOP: 160px; left: 890px;" >
右邊的東西,可以是圖片,表格
< /DIV >"
menus.js的代码如下:
self.onError = null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
function heartBeat(objectid) {
if(IE) { diffY = document.body.scrollTop; diffX = document.body.scrollLeft; }
if(NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }
if(diffY != lastScrollY) {
percent = .1 * (diffY - lastScrollY);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) {
objectid = objectid.split(";");
for (i = 0; i < objectid.length; i ) eval("document.all." objectid[i]).style.pixelTop = percent;
}
if(NS) {
objectid = objectid.split(";");
for (i = 0; i < objectid.length; i ) eval("document." objectid[i]).top = percent;
}
lastScrollY = lastScrollY percent;
}
if(diffX != lastScrollX) {
percent = .1 * (diffX - lastScrollX);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) {
objectid = objectid.split(";");
for (i = 0; i < objectid.length; i ) eval("document.all." objectid[i]).style.pixelLeft = percent;
}
if(NS) {
objectid = objectid.split(";");
for (i = 0; i < objectid.length; i ) eval("document." objectid[i]).left = percent;
}
lastScrollX = lastScrollX percent;
}
}
if(NS || IE) action = window.setInterval("heartBeat(’floater;floater1’)", 2); OK,成功就这么简单!DIV内的文字可以换成图片和表格,ID不改就行了...
另外,记得以上代码为了不干扰本文章的显示,在"<>"中多加了空格,拷贝到文档以后记得修改.
除了上述方法之外,还另从其他网站搜集到另一种实现方法,方法如下:
在显示页面中加入:
< SCRIPT language="JavaScript" src="js/flr.js" >< /SCRIPT >
< SCRIPT language="JavaScript" src="js/fll.js" >< /SCRIPT > ---------------------------flr.js------------------------------------
var imgheight
document.ns = navigator.appName == "Netscape"
window.screen.width>800 ? imgheight=100:imgheight=120
function myload()
{
if (navigator.appName == "Netscape")
{document.dangdang.pageY=pageYOffset window.innerHeight-imgheight-0;
document.dangdang.pageX= window.innerWidth-107;
mymove();
}
else
{
dangdang.style.top=document.body.scrollTop document.body.offsetHeight-imgheight-0;
dangdang.style.left=document.body.offsetWidth-107;
mymove();
}
}
function mymove()
{
if(document.ns)
{
document.dangdang.top=pageYOffset window.innerHeight-imgheight-0;
document.dangdang.left=pageXOffset window.innerWidth-107;
setTimeout("mymove();",50)
}
else
{
dangdang.style.top=document.body.scrollTop document.body.offsetHeight-imgheight-0;
dangdang.style.left=document.body.scrollLeft document.body.offsetWidth-107;
setTimeout("mymove();",50)
}
}
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true)
if (navigator.appName == "Netscape")
{
document.write("href=#’> src=’*.GIF’ width=’80’ height=’80’>");
myload()}
else
{
document.write("
");
myload()
} -------------------------fll.js--------------------------------------
var imgheight
var imgleft
document.ns = navigator.appName == "Netscape"
window.screen.width>800 ? imgheight=110:imgheight=110
window.screen.width>800 ? imgleft=5:imgleft=5
function myload()
{
if (navigator.appName == "Netscape")
{document.myleft.pageY=pageYOffset window.innerHeight-imgheight;
document.myleft.pageX=imgleft;
leftmove();
}
else
{
myleft.style.top=document.body.scrollTop document.body.offsetHeight-imgheight;
myleft.style.left=imgleft;
leftmove();
}
}
function leftmove()
{
if(document.ns)
{
document.myleft.top=pageYOffset window.innerHeight-imgheight
documen
t.myleft.left=imgleft;
setTimeout("leftmove();",80)
}
else
{
myleft.style.top=document.body.scrollTop document.body.offsetHeight-imgheight;
myleft.style.left=imgleft;
setTimeout("leftmove();",80)
}
}
function MM_reloadPage(init) { //reloads the window if Nav4 resized
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
下一篇:超级强大的表单验证代码
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash