Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onfocus="this.blur();" problem

// I am trying to apply an "onfocus="this.blur();"" so as to remove the dotted border lines around pics that are being clicked-on
  // the effect should be applied to all thumb-nail links/a-tags within a div..

  // sudo code (where I am):
  $(".box a").focus(  // so as to effect only a tags within divs of class=box |  mousedown vs. onfocus vs. *** ?? | javascript/jquery... ???
  function () 
  {
      var num = $(this).attr('id').replace('link_no', ''); 
      alert("Link no. " + num + " was clicked on, but I would like an  onfocus=\"this.blur();\" effect to work here instead of the alert...");

      // sudo bits of code that I'm after:
      // $('#link_no' + num).blur();
      // $(this).blur();
      // $(this).onfocus = function () { this.blur(); };


  }
  );

 // the below works for me in firefox and ie also, but I would like it to effect only a tags within my div with class="box"
   function blurAnchors2() 
             {
              if (document.getElementsByTagName) {
                   var a = document.getElementsByTagName("a"); 
                    for (var i = 0; i < a.length; i++) {
                          a[i].onfocus = function () { this.blur(); };
              }
                }
          }
like image 768
Carpenter Avatar asked Sep 06 '25 03:09

Carpenter


1 Answers

Thanks guys - I have gone for the css(a:focus):

img, a:focus{
    outline: none;
}

It seems to be working right(tabbing is still working and the borders are gone when clicking) for me... in both ie and firefox. Will have to now retrofit some other links to use it...

Thanks again.

like image 113
carpenter Avatar answered Sep 07 '25 22:09

carpenter