473,385 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

javascript menu with css

Sorry about the double post, I adjusted the subject to the correct one.

Everything is working right on this except when I press one link, and I

go press another link, I need the previous link to depress. If anyone
can help me with this that would be great.

Here is the code below
<style type="text/css">
..bevelmenu{
font: bold small arial;
padding: 6px 0;
margin: 0;
width: 100%;
background-color: #FFF2BF;
text-align: left; /*set value to "right" for example to align menu to
the right of page*/

}
..bevelmenu a{
font-weight:bold;
background-color:transparent;
padding: 4px;
/*padding: 1px 0.5em;*/
text-decoration: none;
color: white;
/*border: 2px solid #FFF2BF;*/
}
..bevelmenu a:hover{
font-weight:bold;
color: #245EDC;
background-color: white;
border-style: outset;
}
..EPDPSz
{
COLOR: royalblue;
FONT-SIZE: small;
FONT-WEIGHT: bold;
BACKGROUND-COLOR: "aliceblue";
BORDER-BOTTOM: white solid thin;
BORDER-LEFT: gray solid thin;
BORDER-RIGHT: white solid thin;
BORDER-TOP: gray solid thin;
}
html>body .bevelmenu a:active{ /* Apply mousedown effect only to NON IE

browsers */
border-style: inset;

}
</style>

<html>
<head>
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="menubutton.css" />
<base target="main">
<script language="javascript">
function depress(s,f) {
s.className="EPDPSz";
}
</script>
</head>
<body topmargin="0" leftmargin="0">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td height="42">
<div class="bevelmenu">
<a id="1" onMouseDown="depress(this)";
href="http://www.dynamicdrive.com">Test</a>
<a id="2" onMouseDown="depress(this)";
href="http://www.javascriptkit.com">Test2</a>
<a id="3" onMouseDown="depress(this)";
href="http://www.codingforums.com">Test3</a>
<a id="4" onMouseDown="depress(this)";
href="http://www.cssdrive.com">Test4</a>
<a id="5" onMouseDown="depress(this)";
href="http://www.google.com">Test5</a>
<a id="6" onMouseDown="depress(this)";
href="http://www.dynamicdrive.com">Test6</a>
<a id="7" onMouseDown="depress(this)";
href="http://www.javascriptkit.com">Test7</a>
<a id="8" onMouseDown="depress(this)";
href="http://www.codingforums.com">Test8</a>
<a id="9" onMouseDown="depress(this)";
href="http://www.cssdrive.com">Test9</a>
<a id="10" onMouseDown="depress(this)";
href="http://www.google.com">Test10</a>
</div>
</tr></table>
</body>
</html>

Jan 11 '07 #1
1 1038

eripey wrote:
Everything is working right on this except when I press one link, and I

go press another link, I need the previous link to depress. If anyone
can help me with this that would be great.
Solution for this example may look like this:

function depress(s,f)
{
var links = document.getElementsByTagName("a");
for(var i=0; i<links.length; i++)
{
if (links[i] != s)
links[i].className=null;
else
links[i].className="EPDPSz";
}
}

But in a real application you need separate menu items from another
links on a page.
There are many various means to achieve this goal. For example, specify
common name for this items:
<a id="1" name="menuitem" onMouseDown="depress(this)";
href="http://www.dynamicdrive.com">Test</a>
<a id="2" name="menuitem" onMouseDown="depress(this)";
href="http://www.javascriptkit.com">Test2</a>
<a id="3" name="menuitem" onMouseDown="depress(this)";
href="http://www.codingforums.com">Test3</a>
.....

and change script accordingly:
var links = document.getElementsByName("menuitem");
....

Jan 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob McLennan - ZETLAND | last post by:
Hi, I have set up an external stylesheet, named "print.css", to format the style of all pages printed from my company's website. I've been previewing my changes to the stylesheet by doing...
4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
8
by: Rob McLennan - ZETLAND | last post by:
Hi, I have set up an external stylesheet, named "print.css", to format the style of all pages printed from my company's website. I've been previewing my changes to the stylesheet by doing...
7
by: Marci | last post by:
I found this script for cascading menus, however, I cannot reach the author to solve the bug I am having when I add a second menu to it. My problem is this: If I click on the first link, the...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
12
by: tim | last post by:
I am using foldoutmenu 3 and am having problems with viewing my menus in firefox. On my sub3 menus i have more than one line of text in some places. firefox does not recognise that there is more...
3
by: Jlcarroll | last post by:
Hi, I am building a web page.and have a simple javascript menu... I call the javascript menu within a div block that my print sytlesheet has set as a display: none;, well all the content in that...
3
by: wbazarin | last post by:
I am very new using javascript and I faced a problem that with my expertise I cannot solve. I wrote a small html file that handle a vertical menu. I wrote a function to show the menu correctly using...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.