求一个js对联图片悬浮随滚动条滚动代码,左右两边的图片不一样的 可改的!知道的说下 急用!

 我来答
lxs_lingting
2011-10-13 · TA获得超过990个赞
知道小有建树答主
回答量:899
采纳率:100%
帮助的人:508万
展开全部
<script>
var class_name=function()
{
this.top=500;//与顶部距离

//左侧广告
this.l_width=100;//宽
this.l_height=100;//高
this.l_left=100;//与左侧的距离
this.l_src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-zhidao.gif";//图片路径
this.l_url="http://www.baidu.com/";//图片链接地址

//右侧广告
this.r_width=100;//宽
this.r_height=100;//高
this.r_right=100;//与右侧的距离
this.r_src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-zhidao.gif";//图片路径
this.r_url="http://www.baidu.com/";//图片链接地址
}
var c=new class_name();

document.write('<div id="xf_left_gg" style="position:absolute; width:'+c.l_width+'px; heigth:'+c.l_height+'px; left:'+c.l_left+'px; top:'+c.top+'px;"><a href="'+c.l_url+'" target="_blank"><img src="'+c.l_src+'" width="'+c.l_width+'" height="'+c.l_height+'" border="0"></a></div>');
document.write('<div id="xf_right_gg" style="position:absolute; width:'+c.r_width+'px; heigth:'+c.r_height+'px;" right:'+c.r_right+'px; top:'+c.top+'px;"><a href="'+c.l_url+'" target="_blank"><img src="'+c.l_src+'" width="'+c.l_width+'" height="'+c.l_height+'" border="0"></a></div>');

function lxs_xf()
{
var t=(document.body.scrollTop>0)?(parseInt(document.body.scrollTop)+c.top):c.top;
$("xf_left_gg").style.left=c.l_left+"px";
$("xf_left_gg").style.top=t+"px";

$("xf_right_gg").style.right=c.r_right+"px";
$("xf_right_gg").style.top=t+"px";
}
function $(id){return document.getElementById(id);}
if(window.attachEvent)
{
window.attachEvent("onload",lxs_xf);
window.attachEvent("onscroll",lxs_xf);
}
else
{
window.addEventListener("load",lxs_xf,false);
window.addEventListener("scroll",lxs_xf,false);
}
</script>

参考资料: http://hi.baidu.com/lxs_lingting/blog/item/e30a89377289985bad4b5f82.html

快乐走路
2011-10-13 · TA获得超过204个赞
知道答主
回答量:223
采纳率:0%
帮助的人:80万
展开全部
页面调用代码:
<SCRIPT src="left.js"></SCRIPT>
<SCRIPT src="right.js"></SCRIPT>
左侧浮动图片代码,另存为left.js
var imgheight
var imgleft
document.ns = navigator.appName == "Netscape"
window.screen.width>800 ? imgheight=500:imgheight=175
window.screen.width>800 ? imgleft=0:imgleft=20
function myload()
{
if (navigator.appName == "Netscape")
{document.myleft.pageY=pageYOffset+windows.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+windows.innerHeight-imgheight
document.myleft.left=imgleft;
setTimeout("leftmove();",80)
}
else
{
myleft.style.top=document.body.scrollTop;
myleft.style.left=imgleft;
setTimeout("leftmove();",80)
}
}
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("<layer id=myleft top=50 width=80 height=88><a href=#><img src=pic/left2.gif width=100 height=260 border=0></a></layer>"); //图片地址 大小
myload()}
else
{
document.write("<div id=myleft style='position: absolute;width:80;top:100;left:5;visibility: visible;z-index: 1'><a href=#><img src=pic/left2.gif width=122 height=260 border=0></a></div>"); //图片地址

myload()
}
右侧浮动图片代码,另存为right.js
document.ns = navigator.appName == "Netscape"
window.screen.width>800 ? imgheight=265:imgheight=265
window.screen.width>800 ? imgright=0:imgright=100
function threenineload()
{
if (navigator.appName == "Netscape")
{document.threenine.pageY=pageYOffset+windows.innerHeight-imgheight;
document.threenine.pageX=imgright;
threeninemove();
}
else
{
threenine.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight;
threenine.style.right=imgright;
threeninemove();
}
}
function threeninemove()
{
if(document.ns)
{
document.threenine.top=pageYOffset+windows.innerHeight-imgheight
document.threenine.right=imgright;
setTimeout("threeninemove();",80)
}
else
{
threenine.style.top=document.body.scrollTop;
threenine.style.right=imgright;
setTimeout("threeninemove();",80)
}
}
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("<layer id=threenine top=300 width=64 height=80><a href=# target=_blank><img src=pic/left2.gif width=100 height=260 border=0></a></layer>");//图片地址

threenineload()}
else
{
document.write("<div id=threenine style='position: absolute;width:64;top:300;visibility: visible;z-index: 100'><img src=pic/left2.gif width=121 height=260 border=0 usemap=#Mapgame165></div>"); //图片地址
threenineload()
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式