PDA

View Full Version : Css


pinbrook
15-Dec-2003, 10:57 PM
I have 2 sets of link colours defined in actinic.css. This is because some of the site has links on a white background the rest is on a black background.

I need to apply my 2nd set of links in 2 places.

one act-navigation_item this is easy I simply apply the class to the link in the template

two - this is the one I am struggling with, the javascript menu system since i can't wrap this in a class

this is the js (from advanced user guide)

<SCRIPT LANGUAGE = JavaScript>
<!--
function Recurse(pItem)
{
for (var i = 1; i <= pItem.length; i++)
{
document.write("<UL>");
document.write("<LI>");
document.writeln(pItem[i].sName.link(pItem[i].sURL));
document.write("</LI>");
if (pItem[i].pChild)
{
Recurse(pItem[i].pChild);
}
document.write("</UL>");
}
}
Recurse(section_tree);
-->
</SCRIPT>

NormanRouxel
16-Dec-2003, 01:46 AM
Why not put the "class=abcd" into the JavaScript genrated HTML.

E.g.

document.writeln('<div class=myclass>' + pItem[i].sName.link(pItem[i].sURL) + '</div>');

Not sure if this will affect the link but it's worth trying.

If that doesn't work you could use JavaScript to replace something right inside the link to get the class into the <a...> tag.

e.g.

replace

pItem[i].sName.link(pItem[i].sURL)


with

pItem[i].sName.link(pItem[i].sURL).replace(/href=/i,"class=myclass $1")

Again not tested but I hope you get the idea.
Norman

pinbrook
16-Dec-2003, 02:41 AM
Hi Norman

I can't get either piece of code to change my link colours

The top idea, doesn't pick up my class

the 2nd idea doesn't pick up the class and loses the link

NormanRouxel
16-Dec-2003, 05:01 AM
Try replacing the wierd but really concise JavaScript (that .link function isn't in my reference):-

document.writeln(pItem[i].sName.link(pItem[i].sURL));


With

document.write('<a href="' + pItem[i].sURL + '">' + pItem[i].sName + '</a>');

Now you have a more usual type of URL and link that you may be able to add some style into that <a...> tag that's being generated.

Norman

garyhay
16-Dec-2003, 10:03 AM
Jo

I have the attached code using CSS and it works fine

pinbrook
16-Dec-2003, 01:38 PM
Thanks Guys, I've cracked it

document.write('<a href="' + pItem[i].sURL + '" class=darkbg>' + pItem[i].sName + '</a>');