UK Webmaster Talk - Online Marketing - SEO


 

Fading Links

This is a discussion on Fading Links within the Website Design Articles forums, part of the Webmaster Articles/Tutorials category; Have You ever seen a link that changes colour smoothly when the mouse goes over it and changes back smoothly ...


Go Back   UK Webmaster Talk - Online Marketing - SEO > Webmaster Articles > Webmaster Articles/Tutorials > Website Design Articles

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Notices

Reply

 

LinkBack Thread Tools Display Modes
Old 09-04-2005, 11:46   #1 (permalink)
WMT Addict
 
Join Date: Apr 2005
Location: Brighton,UK
Posts: 162
iTrader: 0 / 0%
asgsoft is on a distinguished road
Default Fading Links

Have You ever seen a link that changes colour smoothly when the mouse goes over it and changes back smoothly to normat when the mouse goes of?

Well here is how to do it.

1- Open up note pad and enter in it the following:
PHP Code:
// Fade-to colour without the # (6 character value only!)
var fadeTo "ffaa22";

// Fade in colour increment/decrement by
var fiBy 6;

// Fade out colour increment/decrement by
var foBy 10;

// Speed - milliseconds between each colour change in the fade
// Less than 10ms doesn't really make all that much difference, so
// 10 is the minimum effective value.
var speed 10;

// Class name of links to NOT fade (i.e. ignore)
// var ignoreClass = "somebogusvalue" if you don't want to
// use this feature. Alternatively, add onmouseover="clearFade()"
// to the link you do not wish to fade.
var ignoreClass "ignore";

[
b]// stop editing here[/b]

var operaiedom0ocfaderocs = new Array();

if (
navigator.userAgent.indexOf("Opera") != -1opera true
else if (document.all && !operaie true
else if (!document.all && document.getElementByIddom true;

function 
convertRGB(z)
    {
        var 
newfcS ""splitter "";
        
splitter z.split(",");
        
splitter[0] = parseInt(splitter[0].substring(4splitter[0].length));
        
splitter[1] = parseInt(splitter[1]);
        
splitter[2] = parseInt(splitter[2].substring(0splitter[2].length-1));
        for (var 
03q++)
            {
                
splitter[q] = splitter[q].toString(16);
                if (
splitter[q].length == 1splitter[q] = "0" splitter[q];
                
newfcS += splitter[q];
            }
        return 
newfcS;
    }

function 
currentColour(index)
    {
        var 
tempcc;
        if (
operacc document.links[index].style.color
        
else if (iecc document.links[index].currentStyle.color
        
else if (domcc document.defaultView.getComputedStyle(document.links[index], '').getPropertyValue("color");
        if (
cc.length == && cc.substring(01) == "#")
            {
                
temp "";
                for (var 
03a++)
                    
temp += cc.substring(a+1a+2) + cc.substring(a+1a+2);
                
cc temp;
            }
        else if (
cc.indexOf("rgb") != -1cc convertRGB(cc)
        else if (
cc.length == 7cc cc.substring(17)
        else 
cc fadeTo;
        return 
cc;
    }


function 
convert2Dec(hex)
    {    
        var 
rgb = new Array();
        for (var 
03u++)
            
rgb[u] = parseInt(hex.substring(u*2u*2+2), 16);
        return 
rgb;
    }

function 
newRGB(fnd)
    {
        var 
change;
        if (
== 1change fiBy
        
else change foBy;
        for (var 
03g++)
            {
                if (
n[g] > f[g] && n[g] - change >= 0n[g] -= change;
                if (
n[g] < f[g] && n[g] + change <= 255n[g] += change;
            }
        return 
n;
    }

function 
fade(indexd)
    {
        var 
fcnctemp = new Array(), finished false;
        
nc convert2Dec(currentColour(index));
        if (
== 1fc convert2Dec(fadeTo)
        else 
fc convert2Dec(ocs[x]);
        
temp convert2Dec(currentColour(index));
        
nc newRGB(fcncd);
        if ((
nc[0] == temp[0]) && (nc[1] == temp[1]) && (nc[2] == temp[2]))
            
finished true;
        if (!
finisheddocument.links[x].style.color "rgb(" nc[0] + "," nc[1] + "," nc[2] + ")"
        
else clearInterval(fader);
    }

function 
findLink(over)
    {
        if (
document.layers) return;
        if (
fader)
            {
                
clearInterval(fader);
                
document.links[x].style.color "#" ocs[x];
            }
        if (
over && !this.idthis.id over;
        
0;
        while (!(
this.id == document.links[x].id) && (document.links.length))
            
x++;
        if (
this.id == document.links[x].id)
            {
                
oc currentColour(x);
                
fader setInterval("fade(" x  ", 1)"speed);
            }
    }

function 
clearFade()
    {
        if (
document.layers) return;
        if (
faderclearInterval(fader);
        
fader setInterval("fade(" ", 0)"speed);
    }

function 
init()
    {
        for (var 
0document.links.lengthi++)
            {
                
ocs[i] = currentColour(i);
                var 
currentOver document.links[i].onmouseover;
                var 
currentOut document.links[i].onmouseout;
                var 
ignoreIt document.links[i].className == ignoreClass;
                if (!
ignoreItdocument.links[i].id "link" i;
                if (!
currentOver && !currentOut && !ignoreIt)
                    {
                        
document.links[i].onmouseover findLink;
                        
document.links[i].onmouseout clearFade;
                    }
            }        
}

if (
opera || ie || domwindow.onload init
save it as fader.js
close
open up your webpage

in your body tage document add
HTML Code:
<script type="text/javascript" src="fader.js"></script>

<a href="#">Link 1 </a> 
Check out http://asgsoft.hostmatrix.org/fader1.htm for similler effect.
If you need any help please do not hesitate to contact me
I am sorry but this effect might not work for all browsers.
asgsoft is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-04-2005, 13:12   #2 (permalink)
WMT Addict
 
Join Date: Apr 2005
Location: Singapore
Posts: 238
iTrader: 0 / 0%
Aaron has a spectacular aura about
Send a message via ICQ to Aaron Send a message via AIM to Aaron Send a message via MSN to Aaron Send a message via Yahoo to Aaron
Default

Does this work with PHP-Nuke?
Aaron is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-04-2005, 13:53   #3 (permalink)
WMT Addict
 
Join Date: Apr 2005
Location: Brighton,UK
Posts: 162
iTrader: 0 / 0%
asgsoft is on a distinguished road
Default

i don't think it does but i have seen it with phpbb. but i am unable to do it so.
asgsoft is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 16-04-2005, 11:31   #4 (permalink)
Newbie
 
Join Date: Apr 2005
Posts: 13
iTrader: 0 / 0%
Zaltan will become famous soon enough
Default

I just noticed that that exact code is found at http://developers.evrsoft.com/forum/...hp/t-2301.html, yet you make no reference to anyone of who that script actually belongs to. On that site it is not known whether that is copyright or not, and I doubt that you are the actual author of that site.

Please do not use other peoples works, as copyrighting issues may cause problems for WebmasterTalk. (Like how you were told here and in other cases about copying others' tutorials/scripts.)

Aaron: This is JavaScript, not PHP (as you might assume by the "PHP Code" header), so even though I'm am not entirely sure of what PHP-Nuke is, I doubt that it wont work.
Zaltan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 16-04-2005, 11:37   #5 (permalink)
WMT Addict
 
Join Date: Apr 2005
Location: Singapore
Posts: 238
iTrader: 0 / 0%
Aaron has a spectacular aura about
Send a message via ICQ to Aaron Send a message via AIM to Aaron Send a message via MSN to Aaron Send a message via Yahoo to Aaron
Default

Quote:
Originally Posted by Zaltan
I just noticed that that exact code is found at http://developers.evrsoft.com/forum/...hp/t-2301.html, yet you make no reference to anyone of who that script actually belongs to. On that site it is not known whether that is copyright or not, and I doubt that you are the actual author of that site.

Please do not use other peoples works, as copyrighting issues may cause problems for WebmasterTalk. (Like how you were told here and in other cases about copying others' tutorials/scripts.)

Aaron: This is JavaScript, not PHP (as you might assume by the "PHP Code" header), so even though I'm am not entirely sure of what PHP-Nuke is, I doubt that it wont work.
I see.

PHP-Nuke is a COntent Management System, by the way.
Aaron is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 14-06-2005, 17:50   #6 (permalink)
Super Moderator
 
Lewis's Avatar
 
Join Date: Apr 2005
Location: Leics, UK
Posts: 1,000
iTrader: 0 / 0%
Lewis is just really nice
Send a message via AIM to Lewis Send a message via MSN to Lewis Send a message via Skype™ to Lewis
Default

did you know that the link to your site does not work.
__________________
NewsBarrel.com
Everything is banal and jejune, There is a planetary conspiracy against the likes of you and me in this idiot constituency of the moon, Well, he knew exactly who to blame, And we call upon the author to explain.
Lewis is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
fading, links

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Fading Images asgsoft Website Design Articles 23 08-08-2005 19:15
Fading colours??? Lewis Website Design Forum 2 27-06-2005 05:26


All times are GMT +1. The time now is 00:27.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
UK Webmaster Forum © WebmasterTalk.co.uk | Design by Forbairt

Ad Management by RedTyger

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41