...

View Full Version : link active state?



resin
06-14-2012, 10:00 AM
How can you make a text link return from active to normal link state color after clicking on it? I had this working before but sme reason its not now. Not sure what's missing. Its working correctly in Chrome but not Firefox or IE. Here is page- http://resin.webs.com/new3.html . After clicking link, I want it to return to the normal link color (blue). Currently, it is staying red (active link color) even after the click.

felgall
06-14-2012, 10:40 AM
A link has active state either when the mouse cursor is over it and a mouse button is depressed or when the link has the focus and the enter key is depressed.

To return a link from active state to either hover or focus state simply release the mouse button or enter key. To return it from hover state to normal move the mouse off of it or to return it from focus state to normal press the tab key.

If it stays a different colour after being clicked then that would be caused by the visited state not the active state.

resin
06-14-2012, 12:09 PM
Ok I figured out my problem with that..

But there is one more issue I'm having with the active link state. In Firefox, the active state color doesn't come up at all when I click on the link, if I add this one line of script: document.onmousedown = function() {return false;} . I use this script to prevent text selection in Firefox (since the IE method doesn't work for FF). How can I prevent text selection and allow the active state color appear at the same time, in Firefox?

calsta
06-14-2012, 11:45 PM
the page doesn't exist??

felgall
06-14-2012, 11:53 PM
Ok I figured out my problem with that..

But there is one more issue I'm having with the active link state. In Firefox, the active state color doesn't come up at all when I click on the link, if I add this one line of script: document.onmousedown = function() {return false;} . I use this script to prevent text selection in Firefox (since the IE method doesn't work for FF). How can I prevent text selection and allow the active state color appear at the same time, in Firefox?

You can't prevent text selection in any browser - since the code to do so can easily be disabled without affecting the rest of the page. That such code is pointless is clearly demonstrated by the fact that no major web site attempts to use it.

Your simplest solution is to delete that code. That will in any case make your page more accessible as the code to prevent text selection also prevents some people from being able to view the content at all - unless they turn off JavaScript for the page.

resin
06-15-2012, 06:07 AM
I want to prevent text selection not just to prevent my content being copied, but also because I will have several draggable objects placed around text and images, and it eliminates the possibility of accidently highlighting/selecting other text/objects that aren't meant to be draggable/functional.

Would it be possible to exclude a particular div/element from being affected by document.onmousedown = function() {return false;} ? I tried document.getElementById("new").onmousedown = function() {return true;} but that didn't change anything. Is there another way?

felgall
06-15-2012, 08:27 AM
Get rid of the call disabling it for the entire page and call the following function for the specific parts of the page where you must have it disabled.



disableMousedown = function(id) {
document.getElementById(id).onmousedown = function() {return false;}
}


Better yet attach it using an event listener rather than an event handler so that you can remove it again when you don't need it disabled.

resin
06-16-2012, 08:27 AM
This would work, but after thinking it over more, I really do need the text links themselves to be 'unhighlightable' also. It looks like you can still use onmousedown events on any particular div, when already having the "return false" in the script. So is there something I can place in a particular div's onmousedown that would change the link's color? I tried onmousedown="this.style.color='red'" but that didn't work. But is there something similar?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum