中国开发网: 论坛: 程序员情感CBD: 贴子 393045
haitao
如果直接支持,当然最好了--问题是js的实现好像不标准啊。这2个页面,效果都是可拖移,代码相差很大
http://www.hx66.net/wytx/tx/42.htm

<script language="JavaScript">
//Pre-load your images here.
imgs=new Array("photo/p1.gif","photo/p2.gif","photo/p3.gif","photo/p4.gif","photo/p5.gif")

//Alter nothing past here!
load=new Array()
for(i=0; i < imgs.length; i++){
load[i]=new Image();
load[i].src=imgs[i];
}
var ns=(document.layers);
var ns6=(document.getElementById&&!document.all);
var ie=(document.all);
var n=imgs.length;
var y=null;
var x=null;
var z=null;
var w=null;//Alternate id. Not used for this script.
if (ns||ns6){
window.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
document.releaseEvents(Event.MOUSEMOVE);
}
if (ns){window.onmousedown=down;window.onmouseup=up}
if (ie||document.getElementById){document.onmousedown=down;document.onmouseup=up}
function down(e){
if (ns){
window.onmousemove=move;
if (document.layers['pics'+e.target.name]){
z=document.layers['pics'+e.target.name];
y=e.layerY;
x=e.layerX;
document.layers['pics'+e.target.name].zIndex=n++;
}
else {return true}
w=z.name.charAt(z.name.length-1);
}
if (ie && window.event.srcElement.parentElement){
document.onmousemove=move;
if (window.event.srcElement.parentElement.id.indexOf("pics") != -1){
z=window.event.srcElement.parentElement;
y=window.event.offsetY;
x=window.event.offsetX;
w=window.event.srcElement.parentElement.id.charAt(window.event.srcElement.parentElement.id.length-1);
window.event.srcElement.parentElement.style.zIndex=n++;
}
}
if (ns6){
document.onmousemove=move;
if (e.target.parentNode.id.indexOf("pics") != -1){
z=e.target.parentNode.style;
x=e.clientX - parseInt(z.left);
y=e.clientY - parseInt(z.top);
w=e.target.parentNode.id.charAt(e.target.parentNode.id.length-1);
z.zIndex=n++;
}
}
return false;
}
function move(e){
if (ns && z){z.left=e.pageX-x;z.top=e.pageY-y;}
if (ns6 && z){z.top=parseInt(e.clientY)-y;z.left=parseInt(e.clientX)-x}
if (ie && z){z.style.posLeft=window.event.clientX-x;z.style.posTop=window.event.clientY-y}
return false;
}
function up(e){
if (ie||ns6)document.onmousemove=null;
if (ns)window.onmousemove=null;
z=null;
}
//-->
</script>

<div id="pics0" style="position:absolute;top:10px;left:10px;cursor:move">
<img src="photo/p1.gif" name="0">
</div>

<div id="pics1" style="position:absolute;top:100px;left:10px;cursor:move">
<img src="photo/p2.gif" name="1">
</div>

<div id="pics2" style="position:absolute;top:190px;left:10px;cursor:move">
<img src="photo/p3.gif" name="2">
</div>

<div id="pics3" style="position:absolute;top:280px;left:10px;cursor:move">
<img src="photo/p4.gif" name="3">
</div>

<div id="pics4" style="position:absolute;top:370px;left:10px;cursor:move">
<img src="photo/p5.gif" name="4">
</div>

=================================================================================


http://www.7wind.net/wytx/cd/21.htm

一:将下面的代码放在〈HEAD〉与〈/HEAD〉之间,修改background后的颜色代码
<style>
body,td,a {font-size:9pt;color:black}
.none{border:black 1px solid;background:D9D9D9;padding-top:2}
.over {border:black 1px solid;background:707888;color:white;padding-top:2}
</style>
二:修改<body***>中的内容,将下面的代码加入原<body***>中
onmousemove="move()"
三:将下面的代码复制到〈BODY〉区
<div style="position:absolute; left: 100; top: 100; width: 1; height: 1;cursor: hand" ID=plane onmousedown="down=true;divleft=event.clientX-parseInt(plane.style.left);divtop=event.clientY-parseInt(plane.style.top)"onmouseup="down=false">
<div align=center style="position:absolute; left:150px; top:33px; width:100px; height:19px; z-index:1;color:white;background:707888;cursor:move"onmouseover='stopTimerline();menuItemIn()' onmouseout='runTimerline()' class="none">可拖动的菜单</div>
<div align=center id="item11" style="position:absolute; left:50px; top:55px; width:99px; height:19px; z-index:2; filter:alpha(opacity=0)" onmouseover="this.className='over';stopTimerline()"
onmouseout="this.className='none';runTimerline()" class="none"
>菜单项一</div>
<div align=center id="item12" style="position:absolute; left:250px; top:77px; width:99px; height:19px; z-index:3;filter:alpha(opacity=0)"
class=none onmouseover="this.className='over';stopTimerline()"
onmouseout="this.className='none';runTimerline()">菜单项二</div> <div align=center id="item13" style="position:absolute; left:50px; top:99px; width:99px; height:19px; z-index:4; filter:alpha(opacity=0)"
class=none onmouseover="this.className='over';stopTimerline()"
onmouseout="this.className='none';runTimerline()">菜单项三</div>
<div align=center id="item14" style="position:absolute; left:250px; top:121px; width:99px; height:19px; z-index:5;filter:alpha(opacity=0)"
class=none onmouseover="this.className='over';stopTimerline()"
onmouseout="this.className='none';runTimerline()">菜单项四</div> <div align=center id="item15" style="position:absolute; left:50px; top:143px; width:99px; height:19px; z-index:6; filter:alpha(opacity=0)"
class=none onmouseover="this.className='over';stopTimerline()"
onmouseout="this.className='none';runTimerline()">菜单项五</div>
</div><script>
//动画菜单
var currTimerlinePoint=0
var totalTimerlineFrames=2
var timerlineTimer
var leftLine = 50
var timerIn
var timerOut
var timerlineArray = new Array()
timerlineArray[0]=''
timerlineArray[1]='menuItemOut()'
function runTimerline()
{
window.timerlineTimer = setTimeout('menuItemOut()',500)
}
function stopTimerline()
{
clearTimeout(window.timerlineTimer)
}
function menuItemIn()
{
if( leftLine != 150)
{
item11.style.pixelLeft += 20; item11.filters.alpha.opacity += 20
item12.style.pixelLeft -= 20; item12.filters.alpha.opacity += 20
item13.style.pixelLeft += 20; item13.filters.alpha.opacity += 20
item14.style.pixelLeft -= 20; item14.filters.alpha.opacity += 20
item15.style.pixelLeft += 20; item15.filters.alpha.opacity += 20
leftLine += 20
}
else
{
clearTimeout(window.timerIn)
return false
}
timerIn=window.setTimeout('menuItemIn()',1)
}
function menuItemOut()
{
clearTimeout(window.timerIn)
if (leftLine != 50)
{
item11.style.pixelLeft -= 20; item11.filters.alpha.opacity -= 20
item12.style.pixelLeft += 20; item12.filters.alpha.opacity -= 20
item13.style.pixelLeft -= 20; item13.filters.alpha.opacity -= 20
item14.style.pixelLeft += 20; item14.filters.alpha.opacity -= 20
item15.style.pixelLeft -= 20; item15.filters.alpha.opacity -= 20
leftLine -= 20
}
else
{
clearTimeout(window.timerOut)
return false;
}
timerOut=window.setTimeout("menuItemOut()",1)
}
//移动层
var over=false,down=false,divleft,divtop;function move(){if(down){plane.style.left=event.clientX-divleft;plane.style.top=event.clientY-divtop}}
</script>
我的blog:http://szhaitao.blog.hexun.com & http://www.hoolee.com/user/haitao
--以上均为泛泛之谈--
不尽牛人滚滚来,无边硬伤纷纷现 人在江湖(出来的),哪能不挨刀(总归是要的)
网络对话,歧义纷生;你以为明白了对方的话,其实呢?

您所在的IP暂时不能使用低版本的QQ,请到:http://im.qq.com/下载安装最新版的QQ,感谢您对QQ的支持和使用

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录