473,769 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

background colours gone in dropmenu items

Below dropmenu and javascript modifies ul properties depending on if a link
within matches the current url.

If a match is found the .high style applies to the relevant section, or .low
if no match is found.

This works only for static list, or in the case of a dropmenu, with the
first visible link of each UL only, as tested on Konqueror and Mozilla.

When "position: absolute" is used in conjuction with removing the items from
the page the background-color is gone as they are brought back with the
"left: auto" for some reason, although not other values such as font-size.

Does anyone know why and how to keep the background-color value?

<style type="text/css">
..high {background-color: #99FFCC; font-size: 80%;}
..low {background-color: #33CC00; font-size: 80%;}

..head, .head ul, .low ul {
padding: 0;
margin: 0;
list-style: none;
}

#menu a {
display: block;
width: 10em;
}

..head, .low {
float: left;
width: 10em;
}

..head li ul, .low li ul {
position: absolute;
width: 10em;
left: -999em;
}

..head li:hover ul, low li:hover {
left: auto;
}

</style>
<script type="text/javascript">

function doClass(){
var As, ff, x;
var a = RegExp('.*/'); // Needed many times, compile for speed
var f = document.URL.re place(a,''); // filename of current page
var d = document.getEle mentById('menu' );
var uls = d.getElementsBy TagName('ul');

for (var i=0, j=uls.length; i<j; i++){
x = uls[i];

// If the UL className string includes word 'head'
if ( /\bhead\b/.test(x.classNa me) ){
/* note: add forward slashes around "\bhead\b" if removed by newsreader */

// Get its A elements
As = x.getElementsBy TagName('a');

// Search for matching file names
for (var k=0, m=As.length; k<m; k++) {
ff = As[k].href.replace(a ,'');

// If match, modify the className string of the parent UL
if ( ff == f ){
x.className = x.className.rep lace(/\blow\b/,'high');

// No need to continue once we've found one
return;
}
}
}
}
}
</script>
</head>

<body onload="doClass ();">

<div id="menu">

<ul class="head low">
<li><a href="z0.html"> Flora&nbsp;&amp ;&nbsp;funa</a>

<ul class="sub">
<li><a href="z1.html"> Pretty&nbsp;flo wers</a></li>
<li><a href="z2.html"> Deadly&nbsp;vin es</a></li>
</ul>

</li>
</ul>

<ul class="head low">
<li><a href="z3.html"> Aquatic&nbsp;cr eatures</a>
<ul class="sub">
<li><a href="z4.html"> Pretty&nbsp;fis h</a></li>
<li><a href="z5.html"> Don&#39t&nbsp;eat</a></li>
</ul>
</li>
</ul>

</div>

<div style="clear:le ft">

"To vacillate or not to vacillate, that is the question ... or is it?"

</div>

Jul 21 '05 #1
1 1649
michael wrote:

Below dropmenu and javascript modifies ul properties depending on if a link
within matches the current url.


This isn't a CSS issue, but one of the DOM or JavaScript in general. Try
asking in ng comp.lang.javas cript.

--
Reply email address is a bottomless spam bucket.
Please reply to the group so everyone can share.
Jul 21 '05 #2

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

Similar topics

1
4577
by: Alistair Birch | last post by:
Hi I want rows of a table to appear in alternating background colours. Having looked around the web I can't find any solution apart from waiting for the next version of CSS, so I tried building one myself, but I need some help to finish it. I use the getAttribute('rowIndex') to return the position of a row within the table and apply modulo 2 to return a 0 or 1 indicating an even or odd row number, from which I apply the alternating...
7
27552
by: Thomas Wieser | last post by:
Hi, my problem: I have some tables with transparent backgrounds, which are changed in colours within a JavaScript DOM function to have a roll-over effect. Now, i can't get them back transparent when leaving the mouse out of the rollover-box - background-color: none; seems not to work. Isn't it possible to do this with CSS?
5
14364
by: navavil | last post by:
Hi I used some css class in my web page for graphic design (with url), now when I am sending the page to printer all the background images are gone )-: ? 10x
4
1970
by: david.graham18 | last post by:
Hi I spotted some nice code to change the background colour of a web page to one of four different colours at random but I can't find it now! The method was to select a number at random from 1 to 4 by using the rnd() function and then dividing by modulus 4. The result was then used to select a cell in a 4 cell array which was holding a different colour in each cell of the array. I would like to have this code but lack the knowledge to...
3
4766
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
6
56640
by: Nancy Carter | last post by:
I'm trying to set the background color of a frameset to black. The following code doesn't work in either IE 6.0 or Firefox. Any ideas why? <frameset bgcolor="#000000" frameborder="0" border="0" cols="240,*"> <frame name="links" scrolling="no" noresize target="contents" src=""> <frameset bgcolor="#000000" frameborder="0" border="0" rows="135,*"> <frame name="topbanner" scrolling="no" src="">
4
2154
by: Lachlan Hunt | last post by:
Hi, I'm looking for an interoperable method of determining the current background colour of an element that is set using an external stylesheet. I've tried: elmt.style.backgroundColor; but that only works if the colour has been set using the style attribute or previously set using script. I've also tried:
11
2765
by: shapper | last post by:
Hello, I am trying to create a header with a background color and a padding of the text. I know that if I apply the background color to the header it will expand 100%. So I did the following: <h1><span>Header</span></h1>
2
9722
by: patrick.waldo | last post by:
Hi all, I am trying to figure out a way to read colors with xlrd, but I did not understand the formatting.py module. Basically, I want to sort rows that are red or green. My initial attempt discovered that text:u'test1.txt' (XF:22) text:u'test2.txt' (XF:15) text:u'test3.txt' (XF:15) text:u'test4.txt' (XF:15) text:u'test5.txt' (XF:23)
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.