PDA

View Full Version : Rainbow Links script



Mistymisty
12-30-2006, 08:30 PM
1) Script Title:
Rainbow Links script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex5/rainbow.htm

3) Describe problem:
I'm not having a problem with the script, it's working as it's supposed to.
However, I would like to know if it's possible to exclude the script from working on certain parts of my site.

I'm using external css, and I want the script to NOT apply to any of the links in the "navigation" section.

I -want- the script to apply to all links in the "content" section.

The site I'm working on isn't online yet, so I can't give an url so you can view the source, but if it's necessary I can post the code here...

I hope somebody can help me with this. I tried messing a little around with the rainbow.js script myself, but seeing how I know nothing about how javascript works.... you can guess what the outcome was...

Thanks in advance

jscheuer1
12-30-2006, 10:05 PM
There are two places in the script where the rainbow effect is applied to anchor links, depending upon the browser being used. Two slightly different methods are used to determine if the object is an anchor link. The part you would want to alter is here (for one type browser):


if (obj.tagName == 'A' && obj.href != '') {

and here for the other type:


if (obj.nodeName == 'A' && obj.href != '') {

One way to go would be to also check for a class name to either include or exclude (here we exclude):


if (obj.tagName == 'A' && obj.href != '' && obj.className!='norainbow') {

and:


if (obj.nodeName == 'A' && obj.href != '' && obj.className!='norainbow') {

Now any link like so:


<a class="norainbow" href="page.htm">Page</a>

won't be rainbow. If you do it like so (to include the class name as a requirement):


if (obj.tagName == 'A' && obj.href != '' && obj.className=='rainbow') {

and:


if (obj.nodeName == 'A' && obj.href != '' && obj.className=='rainbow') {

Then only links like so:


<a class="rainbow" href="page.htm">Page</a>

will get the rainbow.

Mistymisty
12-31-2006, 09:38 AM
Used the 'norainbow' method and it works like a charm!
Thank you so much for your help!! :)