Jag är inte så haj på JavaScript, jag har försökt att ändra lite iett script men det fungerar inte som jag vill.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
#divMenu {font-family:arial,helvetica; font-size:12pt; font-weight:bold}
#divMenu a{text-decoration:none;}
#divMenu a:hover{color:red;}
#divMenu2 {font-family:arial,helvetica; font-size:12pt; font-weight:bold}
#divMenu2 a{text-decoration:none;}
#divMenu2 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 @ [url="http://www.bratta.com"]www.bratta.com[/url]
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 [url="http://www.dynamicdrive.com"]http://www.dynamicdrive.com[/url]
********************************************************************************
Browsercheck:*/
ie=document.all?1:0
n=document.layers?1:0
ns6=document.getElementById&&!document.all?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=60
//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 ltop;
var tim=0;
//Object constructor
function makeMenu(obj,nest){
nest=(!nest) ? '':'document.'+nest+'.'
if (n) this.css=eval(nest+'document.'+obj)
else if (ns6) this.css=document.getElementById(obj).style
else if (ie) this.css=eval(obj+'.style')
this.state=1
this.go=0
if (n) this.width=this.css.document.width
else if (ns6) this.width=document.getElementById(obj).offsetWidth
else if (ie) this.width=eval(obj+'.offsetWidth')
this.left=b_getleft
this.obj = obj + "Object"; eval(this.obj + "=this")
}
//Get's the top position.
function b_getleft(){
if (n||ns6){ gleft=parseInt(this.css.left)}
else if (ie){ gleft=eval(this.css.pixelLeft)}
return gleft;
}
/********************************************************************************
Deciding what way to move the menu (this is called onmouseover, onmouseout or onclick)
********************************************************************************/
function moveMenu(menu){
// document.write(menu)
if(!oMenu[menu].state){
clearTimeout(tim)
mIn(menu)
}else{
clearTimeout(tim)
mOut(menu)
}
}
//Menu in
function mIn(menu){
if([menu].left()>-oMenu[menu].width+lshow){
oMenu[menu].go=100
oMenu[menu].css.left=oMenu[menu].left()-move
tim=setTimeout("mIn()",menuSpeed)
}else{
[menu].go=0
[menu].state=1
}
}
//Menu out
function mOut(menu){
if(oMenu[menu].left()<0){
oMenu[menu].go=1
oMenu[menu].css.left=oMenu[menu].left()+move
tim=setTimeout("mOut("+menu+")",menuSpeed)
}else{
oMenu[menu].go=0
oMenu[menu].state=0
}
}
/********************************************************************************
Checking if the page is scrolled, if it is move the menu after
********************************************************************************/
function checkScrolled(menu){
if(!menu.go) menu.css.top=eval(scrolled)+parseInt(ltop)
if(n||ns6) setTimeout('checkScrolled(menu)',30)
}
/********************************************************************************
Inits the page, makes the menu object, moves it to the right place,
show it
********************************************************************************/
function menuInit(){
oMenu=new makeMenu('divMenu')
if (n||ns6) scrolled="window.pageYOffset"
else if (ie) scrolled="document.body.scrollTop"
oMenu.css.left=-oMenu.width+lshow
if (n||ns6) ltop=oMenu.css.top
else if (ie) ltop=oMenu.css.pixelTop
oMenu.css.visibility='visible'
oMenu2=new makeMenu('divMenu2')
if (n||ns6) scrolled="window.pageYOffset"
else if (ie) scrolled="document.body.scrollTop"
oMenu2.css.left=-oMenu.width+lshow
if (n||ns6) ltop=oMenu2.css.top
else if (ie) ltop=oMenu2.css.pixelTop
oMenu2.css.visibility='visible'
}
//Initing menu on pageload
window.onload=menuInit;
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="divMenu" style="position:absolute; top:2; left:30; visibility:hidden; background-color:F0F0F0">
<nobr> <a href="http://www.dynamicdrive.com">Dynamic Drive</a> - <a href="http://www.freewarejava.com/cgi-bin/Ultimate.cgi">WA
Help Forum</a> - <a href="http://active-x.com/">Active-X.com</a> - <a href="javascript://" onClick="moveMenu()" style="background-color:yellow;text-decoration:none">MENU</a>
</nobr> </div>
<div id="divMenu2" style="position:absolute; top:20; left:30; visibility:hidden; background-color:F0F0F0">
<nobr> <a href="http://www.dynamicdrive.com">Dynamic Drive</a> - <a href="http://www.freewarejava.com/cgi-bin/Ultimate.cgi">WA
Help Forum</a> - <a href="http://active-x.com/">Active-X.com</a> - <a href="javascript://" onClick="moveMenu(2)" style="background-color:yellow;text-decoration:none">MENU</a>
</nobr> </div>
</body>
</html>
Jag vill att om man klickar på menu så ska menyn glida ut.
------------------
ja©ob