Welcome to the OzoneAsylum FaqWiki
Frequently Asked Questions
DHTML/JavaScript

How do I get rid of that rectangle when I click on a link? Pages that link to <a href="https://ozoneasylum.com/backlink?for=5031" title="Pages that link to How do I get rid of that rectangle when I click on a link?" rel="nofollow" >How do I get rid of that rectangle when I click on a link?\

It can be annoying when IE leaves that rectangular highlight on your links, especially when they are graphics, but thanks to mr.maX there is a solution.

Add this to the head:

code:
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!-- ;

// Written by mr.maX, http://www.maxworld.co.yu

function removeFocus() {
for (i = 0; i < document.links.length; i++) {
document.links[i].onclick = document.links[i].blur;
}
}

// -->
</script>



and change the body attributes:

code:
<BODY ONLOAD="removeFocus()">



This will kill the rectangle when the page is loaded.

There is another script that removes the rectangle when the focus falls on a link, but it causes problems for those who use TAB to navigate through a page and can cause problems with drop down menus (it is in the first link for those interested).

This is a variation on the original script because it used onfocus instead of onclick. The disadvantage is that the rectangle will be visible between the time the mouse button goes down and comes back up, but the page will be navigatable with the keyboard.


-----------------------


In Mozilla, this can be used in the CSS:

code:
-moz-outline: none;



Also, in IE you can use an expression like this:

code:
a {
selector-dummy: expression(this.hideFocus=true);
}



None of these proprietary CSS styles will validate, though.


-----------------------
Relevant threads:

global script to kill link dots in IE

How do I make an anchor image not seem selected?

Getting rid of the......

ie onClick image highlight

No link selections in IE

______________________
Emperor

(Added by: Emperor on Sun 26-May-2002)
(Edited by: Slime on Sun 26-May-2002)
(Edited by: Emperor on Sun 26-May-2002)
(Edited by: Tyberius Prime on Sun 26-May-2002)
(Edited by: Emperor on Mon 28-Oct-2002)
(Edited by: HZR on Wed 30-Oct-2002)
(Edited by: Rinswind 2th on Thu 08-May-2003)
(Edited by: marty on Sun 07-Sep-2003)
(Edited by kuckus on 09-07-2004 21:47)

« BackwardsOnwards »

Show Forum Drop Down Menu