求一个js对联图片悬浮随滚动条滚动代码,左右两边的图片不一样的 可改的!知道的说下 急用!
2个回答
展开全部
<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>
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
展开全部
页面调用代码:
<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()
}
<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()
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询