Results 1 to 3 of 3

Thread: Rainbow Links script

  1. #1
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Rainbow Links script

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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):

    Code:
    if (obj.tagName == 'A' && obj.href != '') {
    and here for the other type:

    Code:
    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):

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

    Code:
    if (obj.nodeName == 'A' && obj.href != '' && obj.className!='norainbow') {
    Now any link like so:

    HTML Code:
    <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):

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

    Code:
    if (obj.nodeName == 'A' && obj.href != '' && obj.className=='rainbow') {
    Then only links like so:

    HTML Code:
    <a class="rainbow" href="page.htm">Page</a>
    will get the rainbow.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Used the 'norainbow' method and it works like a charm!
    Thank you so much for your help!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •