再来一贴,100分!!!求救

yoyowoho 2003-04-08 03:03:30
把层放到右边,left=500,图片onmouseover使层从右往左移,onmouseout使层回到原位置。急用,谢谢大侠!

<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>

#divMenu {font-family:arial,helvetica; font-size:12pt; font-weight:bold}
#divMenu a{text-decoration:none;}
#divMenu a:hover{color:red;}
</style>
<script language="JavaScript1.2">
/********************************************************************************
Submitted with modifications by Jack Routledge (http://fastway.to/compute) to DynamicDrive.com
Copyright (C) 1999 Thomas Brattli @ www.bratta.com
This script is made by and copyrighted to Thomas Brattli
This may be used freely as long as this msg is intact!
This script has been featured on http://www.dynamicdrive.com
********************************************************************************
Browsercheck:*/
ie=document.all?1:0
n=document.layers?1:0

//These are the variables you have to set:

//How much of the layer do you wan't to be visible when it's in the out state?
lshow=0

//How many pixels should it move every step?
var move=10;

//At what speed (in milliseconds, lower value is more speed)
menuSpeed=40

//Do you want it to move with the page if the user scroll the page?
var moveOnScroll=false

/********************************************************************************
You should't have to change anything below this.
********************************************************************************/
//Defining variables
var tim;
var ltop;

//Object constructor
function makeMenu(obj,nest){
nest=(!nest) ? '':'document.'+nest+'.'
this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')
this.state=1
this.go=0
this.width=n?this.css.document.width:eval(obj+'.offsetWidth')
this.left=b_getleft
this.obj = obj + "Object"; eval(this.obj + "=this")
}
//Get's the top position.
function b_getleft(){
var gleft=(n) ? eval(this.css.left):eval(this.css.pixelLeft);
return gleft;
}
/********************************************************************************
Deciding what way to move the menu (this is called onmouseover, onmouseout or onclick)
********************************************************************************/
function moveMenu(){
if(!oMenu.state){
clearTimeout(tim)
mIn()
}else{
clearTimeout(tim)
mOut()
}
}
//Menu in
function mIn(){
if(oMenu.left()>-oMenu.width+lshow){
oMenu.go=1
oMenu.css.left=oMenu.left()-move
tim=setTimeout("mIn()",menuSpeed)
}else{
oMenu.go=0
oMenu.state=1
}
}
//Menu out
function mOut(){
if(oMenu.left()<0){
oMenu.go=1
oMenu.css.left=oMenu.left()+move
tim=setTimeout("mOut()",menuSpeed)
}else{
oMenu.go=0
oMenu.state=0
}
}
/********************************************************************************
Checking if the page is scrolled, if it is move the menu after 不要的!!!!!!
********************************************************************************/
function checkScrolled(){
if(!oMenu.go) oMenu.css.top=eval(scrolled)+ltop
if(n) setTimeout('checkScrolled()',30)
}
/********************************************************************************
Inits the page, makes the menu object, moves it to the right place,
show it
********************************************************************************/
function menuInit(){
oMenu=new makeMenu('divMenu')
scrolled=n?"window.pageYOffset":"document.body.scrollTop"
oMenu.css.left=-oMenu.width+lshow
ltop=(n)?oMenu.css.top:oMenu.css.pixelTop;
oMenu.css.visibility='visible'
if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
}

//Initing menu on pageload
onload=menuInit;
</script>


</head>

<body bgcolor="#FFFFFF" text="#000000">
<div id="divMenu" style="position:absolute; top:250; left:30; width:200; visibility:hidden; background-color:F0F0F0">
<nobr> <a >网络游戏,版权所有</a>
<a style="background-color:yellow;text-decoration:none">MENU</a>

</nobr> </div>


<table width="262" border="0" cellpadding="0" cellspacing="0" mm:layoutgroup="true">
<tr>
<td width="117" height="25"></td>
<td width="145"></td>
</tr>
<tr>
<td height="46"></td>
<td valign="top"><img onmouseover="moveMenu()" src="file:///E|/images/15_.gif" width="72" height="34"></td>
</tr>
</table>
</body>
</html>


...全文
46 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yoyowoho 2003-04-09
  • 打赏
  • 举报
回复
当鼠标停在divmenu上的时候,divmenu不会收回,该怎么改?
心云意水 2003-04-08
  • 打赏
  • 举报
回复
呵呵~~
看看我上边临时写的那个,未必就比他的那个差……
(现在不够通用化,可以适当修改,多用全局变量,以便适应各种要求……)
皓天星辰 2003-04-08
  • 打赏
  • 举报
回复
在上面有两行

//How much of the layer do you wan't to be visible when it's in the out state?
lshow=1024

其中lshow是层出场的位置,你可以修改它,相应的改小一点适应你的窗口
皓天星辰 2003-04-08
  • 打赏
  • 举报
回复
这样会出现滚动条!!!

<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>

#divMenu {font-family:arial,helvetica; font-size:12pt; font-weight:bold}
#divMenu a{text-decoration:none;}
#divMenu a:hover{color:red;}
</style>
<script language="JavaScript1.2">
/********************************************************************************
Submitted with modifications by Jack Routledge (http://fastway.to/compute) to DynamicDrive.com
Copyright (C) 1999 Thomas Brattli @ www.bratta.com
This script is made by and copyrighted to Thomas Brattli
This may be used freely as long as this msg is intact!
This script has been featured on http://www.dynamicdrive.com
********************************************************************************
Browsercheck:*/
ie=document.all?1:0
n=document.layers?1:0

//These are the variables you have to set:

//How much of the layer do you wan't to be visible when it's in the out state?
lshow=1024

//How many pixels should it move every step?
var move=10;

//At what speed (in milliseconds, lower value is more speed)
menuSpeed=40

//Do you want it to move with the page if the user scroll the page?
var moveOnScroll=false

/********************************************************************************
You should't have to change anything below this.
********************************************************************************/
//Defining variables
var tim;
var ltop;

//Object constructor
function makeMenu(obj,nest){
nest=(!nest) ? '':'document.'+nest+'.'
this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')
this.state=1
this.go=0
this.width=n?this.css.document.width:eval(obj+'.offsetWidth')
this.left=b_getleft
this.obj = obj + "Object"; eval(this.obj + "=this")
}
//Get's the top position.
function b_getleft(){
var gleft=(n) ? eval(this.css.left):eval(this.css.pixelLeft);
return gleft;
}
/********************************************************************************
Deciding what way to move the menu (this is called onmouseover, onmouseout or onclick)
********************************************************************************/
function moveMenu(){
if(!oMenu.state){
clearTimeout(tim)
mIn()
}else{
clearTimeout(tim)
mOut()
}
}
//Menu in
function mIn(){
if(oMenu.left()<lshow){
oMenu.go=1
oMenu.css.left=oMenu.left()+move
tim=setTimeout("mIn()",menuSpeed)
}else{
oMenu.go=0
oMenu.state=1
}
}
//Menu out
function mOut(){
if(oMenu.left()>lshow-oMenu.width){
oMenu.go=1
oMenu.css.left=oMenu.left()-move
tim=setTimeout("mOut()",menuSpeed)
}else{
oMenu.go=0
oMenu.state=0
}
}
/********************************************************************************
Checking if the page is scrolled, if it is move the menu after 不要的!!!!!!
********************************************************************************/
function checkScrolled(){
if(!oMenu.go) oMenu.css.top=eval(scrolled)+ltop
if(n) setTimeout('checkScrolled()',30)
}
/********************************************************************************
Inits the page, makes the menu object, moves it to the right place,
show it
********************************************************************************/
function menuInit(){
oMenu=new makeMenu('divMenu')
scrolled=n?"window.pageYOffset":"document.body.scrollTop"
oMenu.css.left=lshow
ltop=(n)?oMenu.css.top:oMenu.css.pixelTop;
oMenu.css.visibility='visible'
if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
}

//Initing menu on pageload
onload=menuInit;
</script>


</head>

<body bgcolor="#FFFFFF" text="#000000">
<div id="divMenu" style="position:absolute; top:261px; left:780px; width:200; visibility:hidden; background-color:F0F0F0">
<nobr> <a >网络游戏,版权所有</a> <a style="background-color:yellow;text-decoration:none">MENU</a>
</nobr> </div>


<table width="262" border="0" cellpadding="0" cellspacing="0" mm:layoutgroup="true">
<tr>
<td width="117" height="25"></td>
<td width="145"></td>
</tr>
<tr>
<td height="46"></td>
<td valign="top"><img onmouseover="oMenu.state=1;moveMenu();" onMouseOut="oMenu.state=0;moveMenu();" src="file:///E|/images/15_.gif" width="72" height="34"></td>
</tr>
</table>
</body>
</html>
心云意水 2003-04-08
  • 打赏
  • 举报
回复
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>

#divMenu {font-family:arial,helvetica; font-size:12pt; font-weight:bold}
#divMenu a{text-decoration:none;}
#divMenu a:hover{color:red;}
</style>
<script language="JavaScript1.2">
var Timer=null
var Timer1=null
function moveto()
{clearTimeout(Timer)
if(parseInt(divMenu.style.left)<100)
{divMenu.style.visibility=""
clearTimeout(Timer1)
return true
}
divMenu.style.visibility=""
divMenu.style.left=parseInt(divMenu.style.left)-10
Timer1=setTimeout("moveto()",100)
}
function moveback()
{clearTimeout(Timer1)
if(parseInt(divMenu.style.left)>500)
{divMenu.style.visibility=""
clearTimeout(Timer)
return true
}
divMenu.style.left=parseInt(divMenu.style.left)+10
Timer=setTimeout("moveback()",100)
}
</script>


</head>

<body bgcolor="#FFFFFF" text="#000000">
<div id="divMenu" style="position:absolute; top:250; left:500; width:200; visibility:hidden; background-color:F0F0F0">
<nobr> <a >网络游戏,版权所有</a>
<a style="background-color:yellow;text-decoration:none">MENU</a>

</nobr> </div>

<table width="262" border="0" cellpadding="0" cellspacing="0" mm:layoutgroup="true">
<tr>
<td width="117" height="25"></td>
<td width="145"></td>
</tr>
<tr>
<td height="46"></td>
<td valign="top"><img onmouseover="moveto()" onmouseout="moveback()" src="file:///E|/images/15_.gif" width="72" height="34"></td>
</tr>
</table>
</body>
</html>
yoyowoho 2003-04-08
  • 打赏
  • 举报
回复
还是从左往右啊,我想让它从右往左拉出
dkmilk 2003-04-08
  • 打赏
  • 举报
回复
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>

#divMenu {font-family:arial,helvetica; font-size:12pt; font-weight:bold}
#divMenu a{text-decoration:none;}
#divMenu a:hover{color:red;}
</style>
<script language="JavaScript1.2">
/********************************************************************************
Submitted with modifications by Jack Routledge (http://fastway.to/compute) to DynamicDrive.com
Copyright (C) 1999 Thomas Brattli @ www.bratta.com
This script is made by and copyrighted to Thomas Brattli
This may be used freely as long as this msg is intact!
This script has been featured on http://www.dynamicdrive.com
********************************************************************************
Browsercheck:*/
ie=document.all?1:0
n=document.layers?1:0

//These are the variables you have to set:

//How much of the layer do you wan't to be visible when it's in the out state?
lshow=0

//How many pixels should it move every step?
var move=10;

//At what speed (in milliseconds, lower value is more speed)
menuSpeed=40

//Do you want it to move with the page if the user scroll the page?
var moveOnScroll=false

/********************************************************************************
You should't have to change anything below this.
********************************************************************************/
//Defining variables
var tim;
var ltop;

//Object constructor
function makeMenu(obj,nest){
nest=(!nest) ? '':'document.'+nest+'.'
this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')
this.state=1
this.go=0
this.width=n?this.css.document.width:eval(obj+'.offsetWidth')
this.left=b_getleft
this.obj = obj + "Object"; eval(this.obj + "=this")
}
//Get's the top position.
function b_getleft(){
var gleft=(n) ? eval(this.css.left):eval(this.css.pixelLeft);
return gleft;
}
/********************************************************************************
Deciding what way to move the menu (this is called onmouseover, onmouseout or onclick)
********************************************************************************/
function moveMenu(){
if(!oMenu.state){
clearTimeout(tim)
mIn()
}else{
clearTimeout(tim)
mOut()
}
}
//Menu in
function mIn(){
if(oMenu.left()>-oMenu.width+lshow){
oMenu.go=1
oMenu.css.left=oMenu.left()-move
tim=setTimeout("mIn()",menuSpeed)
}else{
oMenu.go=0
oMenu.state=1
}
}
//Menu out
function mOut(){
if(oMenu.left()<0){
oMenu.go=1
oMenu.css.left=oMenu.left()+move
tim=setTimeout("mOut()",menuSpeed)
}else{
oMenu.go=0
oMenu.state=0
}
}
/********************************************************************************
Checking if the page is scrolled, if it is move the menu after 不要的!!!!!!
********************************************************************************/
function checkScrolled(){
if(!oMenu.go) oMenu.css.top=eval(scrolled)+ltop
if(n) setTimeout('checkScrolled()',30)
}
/********************************************************************************
Inits the page, makes the menu object, moves it to the right place,
show it
********************************************************************************/
function menuInit(){
oMenu=new makeMenu('divMenu')
scrolled=n?"window.pageYOffset":"document.body.scrollTop"
oMenu.css.left=-oMenu.width+lshow
ltop=(n)?oMenu.css.top:oMenu.css.pixelTop;
oMenu.css.visibility='visible'
if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
}

//Initing menu on pageload
onload=menuInit;
</script>


</head>

<body bgcolor="#FFFFFF" text="#000000">
<div id="divMenu" style="position:absolute; top:250; left:30; width:200; visibility:hidden; background-color:F0F0F0">
<nobr> <a >网络游戏,版权所有</a>
<a style="background-color:yellow;text-decoration:none">MENU</a>

</nobr> </div>


<table width="262" border="0" cellpadding="0" cellspacing="0" mm:layoutgroup="true">
<tr>
<td width="117" height="25"></td>
<td width="145"></td>
</tr>
<tr>
<td height="46"></td>
<td valign="top"><img onmouseover="moveMenu()" onmouseout="moveMenu()" src="file:///E|/images/15_.gif" width="72" height="34"></td>
</tr>
</table>
</body>
</html>

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧