Dark Dragon
08-18-2003, 01:58 PM
I am experimenting with some Javascript code, more precisely, a code to have a horizontally sliding menu.
Here is the code I copied, pasted and edited:
<html>
<head>
<style>
body{font-family:arial;}
a{color:black;text-decoration:none;font:bold}
a:hover{color:#606060}
td.menu{background:lightblue}
table.nav
{
background:black;
position:relative;
font:bold 80%;
top:0;
left:-135;
}
</style>
<script type="text/javascript">
var i=-135
var c=0
var intHide
var speed=15
function show_hide_menu()
{
if (c==0)
{
c=1
clearInterval(intHide)
intShow=setInterval("show()",10)
}
else
{
c=0
clearInterval(intShow)
intHide=setInterval("hide()",10)
}
}
function show()
{
if (i<-12)
{
i=i+speed
myMenu.style.left=i
}
}
function hide()
{
if (i>-135)
{
i=i-speed
myMenu.style.left=i
}
}
</script>
</head>
<body>
<table id="myMenu" class="nav" width="150" onclick="show_hide_menu()">
<tr><td class="menu"><a href="/default.asp">HOME</a></td>
<td rowspan="5" align="center" bgcolor="#FF8080">M<br>E<br>N<br>U</td></tr>
<tr><td class="menu"><a href="/asp/default.asp">Tips</a></td></tr>
<tr><td class="menu"><a href="/js/default.asp">Tutorials</a></td></tr>
<tr><td class="menu"><a href="default.asp">About</a></td></tr>
<tr><td class="menu"><a href="/vbscript/default.asp">Artwork</a></td></tr>
</table>
</body>
</html>
The difficulty lies in the fact that it doesn't seem to want to function with IE, or shall I say, the menu won't slide like it is supposed to even though the site where I copied the code from worked flawlessly. So I am curious if I left something out or does something else need to be "tweaked". This is really the first time I used Javascript so I am not really all that familiar with it :D
Here is the code I copied, pasted and edited:
<html>
<head>
<style>
body{font-family:arial;}
a{color:black;text-decoration:none;font:bold}
a:hover{color:#606060}
td.menu{background:lightblue}
table.nav
{
background:black;
position:relative;
font:bold 80%;
top:0;
left:-135;
}
</style>
<script type="text/javascript">
var i=-135
var c=0
var intHide
var speed=15
function show_hide_menu()
{
if (c==0)
{
c=1
clearInterval(intHide)
intShow=setInterval("show()",10)
}
else
{
c=0
clearInterval(intShow)
intHide=setInterval("hide()",10)
}
}
function show()
{
if (i<-12)
{
i=i+speed
myMenu.style.left=i
}
}
function hide()
{
if (i>-135)
{
i=i-speed
myMenu.style.left=i
}
}
</script>
</head>
<body>
<table id="myMenu" class="nav" width="150" onclick="show_hide_menu()">
<tr><td class="menu"><a href="/default.asp">HOME</a></td>
<td rowspan="5" align="center" bgcolor="#FF8080">M<br>E<br>N<br>U</td></tr>
<tr><td class="menu"><a href="/asp/default.asp">Tips</a></td></tr>
<tr><td class="menu"><a href="/js/default.asp">Tutorials</a></td></tr>
<tr><td class="menu"><a href="default.asp">About</a></td></tr>
<tr><td class="menu"><a href="/vbscript/default.asp">Artwork</a></td></tr>
</table>
</body>
</html>
The difficulty lies in the fact that it doesn't seem to want to function with IE, or shall I say, the menu won't slide like it is supposed to even though the site where I copied the code from worked flawlessly. So I am curious if I left something out or does something else need to be "tweaked". This is really the first time I used Javascript so I am not really all that familiar with it :D